The In-Memory Cache Manager
As the name implies, all the data in the in-memory cache is stored in primary memory. This means the data is deleted when the application is shut down, but there is a persistence mechanism for saving the data. A database-intensive application could end up using a large amount of memory, but there are provisions for clearing memory as well.
If an error occurs during an attempt to access the cache, the cache manager obtains a copy of the
RWDBStatus object from the calling object and populates it as described in Section 1.4.3. With the in-memory cache manager, the only way to capture the error is by installing an error handler.
The Rogue Wave implementation of the cache manager extends the methods defined in the base class to include operators for persisting a cache to a stream or a file. These operators allow you to persist and restore a cache across runs of the application. These operators are:
RWFile& operator<<(RWFile &file, const RWDBInMemoryCacheManager& cm);
RWvostream& operator<<(RWvostream &strm, const RWDBInMemoryCacheManager& cm);
RWFile& operator>>(RWFile &file, RWDBInMemoryCacheManager& cm);
RWvistream& operator>>(RWvistream &strm, RWDBInMemoryCacheManager& cm);
To deal with the possible problem of the cache consuming too much memory, the Rogue Wave implementation provides a method for clearing the data in the cache:
void removeAll();
By default, this method passes the enum value both, which means it removes all of the data for both tables and stored procedures. You can instead pass the values table or storedProc to remove all of the data for one or the other type of object.
Of course, you may not want to clear everything from the cache, but just certain things. To clear cached data for just a single table or stored procedure, you can create an empty
RWDBTableEntry or
RWDBStoredProcEntry object and set it on the cache. To clear particular data for a table or stored procedure, obtain its entry from the cache, set empty data on the items you want to clear, and re-set the altered entry on the cache. See the descriptions for
RWDBTableEntry and
RWDBStoredProcEntry in the
SourcePro API Reference Guide for information on the methods available to you.