Search code examples
sqlitevfswal

SQLite WAL-mode, in-memory, database with private cache?


I am working on a project which relies on the read snapshot isolation that the WAL journal mode provides in Sqlite. It uses multiple connections to the same database to allow concurrent readers and a single writer.

For testing, I would like to use an in-memory database, but as far as I can tell, that requires SQLITE_OPEN_SHAREDCACHE (which invalidates the read snapshot isolation guarantee that WAL mode provides).

Is there any way to open multiple connections to an in-memory, WAL mode, SQLite database in private cache mode?

Is there possibly a (pre-existing) VFS solution to this problem?

WAL-mode docs


Solution

  • WAL mode does not apply to in-memory databases.

    To get WAL (and read snapshot isolation), you need to use a temporary database on disk. (This disk could be a RAM disk.)