Implementing a Cache Manager
The Rogue Wave implementation provides an easy way to use caching, but it may not always be practical to store metadata in-memory, or you may have other caching requirements, such as wanting to share the cache between processes.
To implement your own cache manager, derive from
RWDBCacheManager and implement the
get() and
set() methods defined in the base class. You can use the implementation of
RWDBInMemoryCacheManager as a model for writing your implementation. Keep in mind these requirements:
Error handling. The only requirement here is to detect problems and throw exceptions. The Rogue Wave methods that use the cache manager respond to the exceptions as described in
Error Handling in the Cache Manager. Of course you are free to implement whatever additional error handling you wish.
Thread safety. The Rogue Wave methods that use the cache manager do not assume it is thread-safe and so obtain a lock on the
RWDBDatabase object that holds the cache manager before changing any data. We do not recommend manipulating the cache any other way.
One option available to you is to make your cache manager more fine-grained than the in-memory cache manager that Rogue Wave supplies. The in-memory cache manager stores and retrieves metadata only through the
RWDBTableEntry and
RWDBStoredProcEntry objects. However, in implementing your own cache manager, you have access to these objects and all of the methods for setting, getting, checking the existence of, and clearing the particular types of data the cache can store, such as primary keys and stored procedure parameters. So you are free to deal with different parts of the cacheable data in different ways.
Another clear option is to implement one or more different ways of storing and persisting the cached data. The in-memory cache manager is implemented entirely in primary memory. You might prefer to store the data using some different mechanism, or even two or more mechanisms for different parts of the data. Similarly, the in-memory cache manager provides methods to persist data to a file or a stream, but you may prefer other ways of persisting the data.