Programmatically Refreshing the Microsoft Jet Cache

To improve performance in Microsoft Jet 3.0, the behavior of the PageTimeout setting was altered. In Microsoft Jet 2.x, if you set the PageTimeout setting to 2 seconds, a shared cache is kept at least 2 seconds, and probably longer before Microsoft Jet refreshes data in its cache. In Microsoft Jet 3.0, the cache is kept no more than 2 seconds, providing more precise control over the currency of the data returned. The default value for the PageTimeout setting in both Microsoft Jet 3.0 and 3.5 is 5000 milliseconds. In addition, Microsoft Jet 3.0 and 3.5 recognize when shared databases are not being updated, and suppress cache refreshing. In this way, performance of shared databases that are infrequently changed may approach the performance of databases that are open exclusively.

Although these changes prove optimal for performance, a drawback is that almost ten seconds may elapse before a user in a shared database can see changes made by other users. One way to work around this problem is to set the PageTimeout registry setting to a lower value. However, doing this degrades the performance of Microsoft Jet by forcing it to read the database header more frequently, which results in increased I/O.

Microsoft Jet 3.5 addresses this problem by providing a way to force its cache to be refreshed regardless of the PageTimeout setting. The Idle method of the DBEngine object has a new argument, dbRefreshCache, that you can use to force Microsoft Jet to immediately read the database header to see if any changes have occurred. If they have, Microsoft Jet refreshes its cache and the user of the application that issued the command sees any changes made by other users. This change allows you to leave the PageTimeout setting at its default to provide optimal performance, but gives you the ability to force Microsoft Jet to check for other users’ changes. However, keep in mind that just as setting PageTimeout to a low value can degrade performance, using the dbRefreshCache argument of the Idle method repeatedly will increase disk and network I/O and degrade performance.