A Database Client Perspective
As noted previously, caching data and metadata locally can dramatically decrease the amount of network traffic incurred by a program. Furthermore, caching often allows the database server to optimize its resource usage. Both techniques result in better performance.
In some classes of the DB Interface Module, caching is employed automatically to provide the best performance in areas where it can safely be used. The classes RWDBInserter, RWDBReader, and RWDBEnvironmentHandle all provide caching options for inserting and reading data including the caching of result schemas. These options, which are discussed in the following sections, allow you to make specific choices about how information is cached inside the DB Interface Module.
The classes RWDBTable and RWDBStoredProc provide local caching of database table and stored procedure metadata such as table schemas, table primary keys, stored procedure parameters, and stored procedure text. This improves performance by fetching the metadata from the database just once for each RWDBTable or RWDBStoredProc object.
Metadata caching can be extended across multiple RWDBTable and RWDBStoredProc objects by registering a cache manager derived from RWDBCacheManager with an RWDBDatabase object. Once registered, the cache manager stores the fetched metadata globally, at the RWDBDatabase level, in addition to the local cache in each RWDBTable and RWDBStoredProc object. This provides even better performance because metadata for a particular database table or stored procedure needs to be fetched only once and is then available to all RWDBTable and RWDBStoredProc objects that reference it.
As defined by the base class RWDBCacheManager, the cache manager stores and accesses metadata through the objects RWDBTableEntry and RWDBStoredProcEntry. So the main cache manager methods on these objects are set() and get():
 
void setTable(const RWCString& key, const RWDBTableEntry& entry);
void setStoredProc(const RWCString& key, const RWDBStoredProcEntry& entry);
 
RWDBTableEntry getTable(const RWCString& key) const;
RWDBStoredProcEntry getStoredProc(const RWCString& key) const;
The parameter key is always the table or stored procedure name for the data being cached. Since these methods are always called by an RWDBTable or an RWDBStoredProc object, the object knows the name and passes it, and the cache manager uses the name to map to the stored data.
The get() methods return an entry object, either the existing object in the cache, or an empty object if the cache does not have an entry. The original calling method then examines the entry object to determine whether it contains the data it wants. If not, it queries the database for the data and then uses the set() method to put an updated entry object into the cache.
For detailed descriptions of the caching behavior in the classes mentioned above, please see the SourcePro API Reference Guide.
NOTE: For caching during data insertion and retrieval, please see your Access Module guide for restrictions specific to your vendor. For metadata caching with a cache manager, there are no known access module-specific restrictions.