SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Protected Member Functions
RWDBCacheManager Class Reference

Base class for user-defined metadata cache managers. More...

#include <rw/db/cachemgr.h>

Inheritance diagram for RWDBCacheManager:
RWDBInMemoryCacheManager

Public Member Functions

virtual ~RWDBCacheManager ()
 
virtual RWDBStoredProcEntry getStoredProc (const RWCString &key) const
 
virtual RWDBTableEntry getTable (const RWCString &key) const
 
virtual void setStoredProc (const RWCString &key, const RWDBStoredProcEntry &spEntry)
 
virtual void setTable (const RWCString &key, const RWDBTableEntry &tableEntry)
 

Protected Member Functions

 RWDBCacheManager ()
 
 RWDBCacheManager (const RWDBCacheManager &)
 

Detailed Description

RWDBCacheManager is a base class for implementing the caching of schema metadata. The types of metadata that is cached are defined RWDBTableEntry and RWDBStoredProcEntry. Caching this data allows the program to create and use RWDBTable and RWDBStoredProc ojects with fewer queries to the database.

Install an instance of a cache manager class derived from RWDBCacheManager, in only one instance of RWDBDatabase. A cache manager instance may not be shared with multiple RWDBDatabase instances. If you need to access the currently installed cache manager, acquire the global lock to the RWDBDatabase and then release it when done via the methods RWDBDatabase::acquire() and RWDBDatabase::release(). The cache manager must remain in scope for the lifetime of the RWDBDatabase instance in which it is installed.

Please refer to the DB Interface Module User's Guide and the applicable DB Access Module User's Guide for more information on caching metadata.

See also
RWDBInMemoryCacheManager
Synopsis
#include <rw/db/cachemgr.h>
Example
#include <rw/db/cachemgr.h>
#include <rw/tvhmap.h>
class MyCacheManager : public RWDBCacheManager
{
void setTable(const RWCString& name, const RWDBTableEntry& tEntry) {
tCache.insert(name, tEntry);
}
void setStoredProc(const RWCString& name, const RWDBStoredProcEntry& spEntry) {
spCache.insert(name, spEntry);
}
RWDBTableEntry getTable(const RWCString& name) const {
tCache.findValue(name, tEntry);
return tEntry;
}
spCache.findValue(name, spEntry);
return spEntry;
}
private:
};
int main()
{
MyCacheManager cache;
RWDBManager::database("accessLib", "Servername",
"Username", "Password", "DatabaseName");
db.cacheManager(&cache);
}

Constructor & Destructor Documentation

virtual RWDBCacheManager::~RWDBCacheManager ( )
virtual

Destructor.

RWDBCacheManager::RWDBCacheManager ( )
protected

Default constructor.

RWDBCacheManager::RWDBCacheManager ( const RWDBCacheManager )
protected

Copy constructor.

Member Function Documentation

virtual RWDBStoredProcEntry RWDBCacheManager::getStoredProc ( const RWCString key) const
virtual

This method is called whenever we need any stored procedure metadata from the cache. If the key is not in the cache, this method returns an empty RWDBStoredProcEntry. The key is the return value of RWDBStoredProc::name().

The default implementation returns an empty RWDBStoredProcEntry.

Reimplemented in RWDBInMemoryCacheManager.

virtual RWDBTableEntry RWDBCacheManager::getTable ( const RWCString key) const
virtual

This method is called whenever we need any table metadata from the cache. If the key is not in the cache, this method returns an empty RWDBTableEntry. The key is the return value of RWDBTable::name().

The default implementation returns an empty RWDBTableEntry.

Reimplemented in RWDBInMemoryCacheManager.

virtual void RWDBCacheManager::setStoredProc ( const RWCString key,
const RWDBStoredProcEntry spEntry 
)
virtual

This method is called whenever we have fetched any stored procedure metadata from the database and need to cache it. The key is the return value of RWDBStoredProc::name(), and the spEntry contains all stored procedure metadata.

The default implementation is a no-op.

Reimplemented in RWDBInMemoryCacheManager.

virtual void RWDBCacheManager::setTable ( const RWCString key,
const RWDBTableEntry tableEntry 
)
virtual

This method is called whenever we have fetched any table metadata from the database and need to cache it. The key is the return value of RWDBTable::name(), and the tableEntry contains all table metadata.

The default implementation is a no-op.

Reimplemented in RWDBInMemoryCacheManager.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.