CacheSize Property

See Also    Example    Applies To   

Sets or returns the number of records retrieved from an ODBC data source that will be cached locally.

Settings and Return Values

The setting or return value is a Long value and must be between 5 and 1200, but not greater than available memory will allow. A typical value is 100. A setting of 0 turns off caching.

Remarks

Data caching improves performance if you use Recordset objects to retrieve data from a remote server. A cache is a space in local memory that holds the data most recently retrieved from the server; this is useful if users request the data again while the application is running. When users request data, the Microsoft Jet database engine checks the cache for the requested data first rather than retrieving it from the server, which takes more time. The cache only saves data that comes from an ODBC data source.

Any Microsoft Jet-connected ODBC data source, such as a linked table, can have a local cache. To create the cache, open a Recordset object from the remote data source, set the CacheSize and CacheStart properties, and then use the FillCache method, or step through the records by using the Move methods.

An ODBCDirect workspace can use a local cache. To create the cache, set the CacheSize property on a QueryDef object. On a Relation object, CacheSize is read-only and depends on the value of the QueryDef object's CacheSize property. You can't use the CacheStart property on FillCache method in an ODBCDirect workspace. In a Microsoft Jet workspace, the CacheSize property is not available on a QueryDef object.

You can base the CacheSize property setting on the number of records your application can handle at one time. For example, if you're using a Recordset object as the source of the data to be displayed on screen, you could set its CacheSize property to 20 to display 20 records at one time.

The Microsoft Jet database engine requests records within the cache range from the cache, and it requests records outside the cache range from the server.

Records retrieved from the cache don't reflect concurrent changes that other users made to the source data.

To force an update of all the cached data, set the CacheSize property of the Recordset object to 0, re-set it to the size of the cache you originally requested, and then use the FillCache method.