sqlite如何在不同进程间同步page cache?
How does sqlite synchronize page cache among different processes?
我知道sqlite在进程内使用缓存页来提高读取性能,另外,sqlite通过应用文件级锁机制允许多进程访问同一个sqlite数据库文件。我的问题是:如果进程 A 更新了页面 x,同时进程 B 缓存了页面 X,进程 B 会读取停滞值还是有机制通知进程 B 更改?
来自the documentation的数据库文件格式:
The file change counter is a 4-byte big-endian integer at offset 24 that is incremented whenever the database file is unlocked after having been modified. When two or more processes are reading the same database file, each process can detect database changes from other processes by monitoring the change counter. A process will normally want to flush its database page cache when another process modified the database, since the cache has become stale. The file change counter facilitates this.
所以,是的,有一种方法可以在修改数据库时通知其他连接,以便他们可以使缓存无效。
我知道sqlite在进程内使用缓存页来提高读取性能,另外,sqlite通过应用文件级锁机制允许多进程访问同一个sqlite数据库文件。我的问题是:如果进程 A 更新了页面 x,同时进程 B 缓存了页面 X,进程 B 会读取停滞值还是有机制通知进程 B 更改?
来自the documentation的数据库文件格式:
The file change counter is a 4-byte big-endian integer at offset 24 that is incremented whenever the database file is unlocked after having been modified. When two or more processes are reading the same database file, each process can detect database changes from other processes by monitoring the change counter. A process will normally want to flush its database page cache when another process modified the database, since the cache has become stale. The file change counter facilitates this.
所以,是的,有一种方法可以在修改数据库时通知其他连接,以便他们可以使缓存无效。