Sets or returns the number of records retrieved from an ODBC data source that will be cached locally.
Syntax
VOIDSetCacheSize(LONG lSize);
LONGGetCacheSize(VOID);
Parameters
Type | Argument | Description |
LONG | lSize | A Long between 5 and 1200 (limited by available memory) which specifies the number of records that will be cached locally. A typical value is 100. A setting of 0 turns off caching. |
Remarks
Data caching improves performance if you use CdbRecordset 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 CdbRecordset 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 CdbQueryDef object. On a CdbRelation object, CacheSize is read-only and depends on the value of the CdbQueryDef object's CacheSize property. You can't use the CacheStart property on the FillCache method in an ODBCDirect workspace.
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 CdbRecordset 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 CdbRecordset object to 0, re-set it to the size of the cache you originally requested, and then use the FillCache method.