SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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;
}
RWDBStoredProcEntry getStoredProc(const RWCString& name) const {
spCache.findValue(name, spEntry);
return spEntry;
}
private:
};
int main() {
MyCacheManager cache;
"accessLib", "Servername", "Username", "Password", "DatabaseName");
db.cacheManager(&cache);
}
Offers powerful and convenient facilities for manipulating strings.
Definition stdcstring.h:826
Base class for user-defined metadata cache managers.
Definition cachemgr.h:637
Manages connections with database servers.
Definition dbase.h:91
RWDBCacheManager * cacheManager() const
static RWDBDatabase database(const RWCString &serverType, const RWCString &serverName, const RWCString &userName, const RWCString &password, const RWCString &databaseName, const RWDBDatabaseCallback &databasecb=RWDBDatabaseCallback())
Class to hold RWDBStoredProc metadata for cache managers.
Definition cachemgr.h:55
Class to hold RWDBTable metadata for cache managers.
Definition cachemgr.h:253
Maintains a collection of keys, each with an associated item stored according to a hash object.
Definition tvhdict.h:144

Constructor & Destructor Documentation

◆ ~RWDBCacheManager()

virtual RWDBCacheManager::~RWDBCacheManager ( )
virtual

Destructor.

◆ RWDBCacheManager() [1/2]

RWDBCacheManager::RWDBCacheManager ( )
protected

Default constructor.

◆ RWDBCacheManager() [2/2]

RWDBCacheManager::RWDBCacheManager ( const RWDBCacheManager & )
protected

Copy constructor.

Member Function Documentation

◆ getStoredProc()

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.

◆ getTable()

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.

◆ setStoredProc()

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.

◆ setTable()

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 © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.