|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.objectweb.cjdbc.controller.cache.AbstractRequestCache
org.objectweb.cjdbc.controller.cache.QueryCache
This is a query cache implementation with tunable granularity.
Cache invalidation granularity can take on of the following values:
NO_INVALIDATE: no invalidation, the cache is inconsistent
and this should just be used to determine hit ratio upper bound.DATABASE: the cache is flushed each time the database is
updated (every INSERT, UPDATE, DELETE, ... statement).TABLE: table granularity, entries in the cache are
invalidated based on table dependencies.COLUMN: column granularity, entries in the cache are
invalidated based on column dependenciesCOLUMN_UNIQUE: same as COLUMN except that
UNIQUE queries that selects a single row based on a key are not
invalidated on INSERT.
| Field Summary | |
private int |
cacheGrain
|
private CacheDatabaseSchema |
cdbs
|
private java.util.Hashtable |
entriesForTransaction
|
private QueryCacheEntry |
lruHead
|
private QueryCacheEntry |
lruTail
|
private java.util.HashSet |
pendingQueries
|
private java.util.Hashtable |
queries
|
private CacheStatistics |
stats
|
| Fields inherited from class org.objectweb.cjdbc.controller.cache.AbstractRequestCache |
logger, parsingGranularity, pendingQueryTimeout |
| Constructor Summary | |
QueryCache(int cacheGranularity)
Creates a new Cache instance. |
|
| Method Summary | |
void |
addToCache(SelectRequest request,
java.sql.ResultSet result)
Adds an entry request/reply to the cache. |
void |
commit(TransactionMarkerMetaData tm)
Commit a transaction given its id. |
void |
flushCache()
Removes all entries from the cache. |
QueryCacheEntry |
getFromCache(SelectRequest request,
boolean addToPendingQueries)
Gets the result to the given request from the cache. |
java.lang.String |
getInformation()
Gets information about the request cache |
int |
getParsingGranularity()
Gets the needed query parsing granularity. |
java.lang.String |
getXmlInformation()
Gets information about the request cache |
private void |
initQueryCache(int cacheGranularity)
|
void |
mergeDatabaseSchema(DatabaseSchema dbs)
Merge the given DatabaseSchema with the current one. |
void |
removeFromCache(SelectRequest request)
Removes an entry from the cache (both request and reply are dropped). |
protected void |
removeOldest()
Removes the oldest entry from the cache. |
void |
rollback(TransactionMarkerMetaData tm)
Rollback a transaction given its id. |
void |
setDatabaseSchema(DatabaseSchema dbs)
Sets the DatabaseSchema of the current virtual database. |
void |
writeNotify(AbstractWriteRequest request)
Notifies the cache that this write request has been issued, so that cache coherency can be maintained. |
| Methods inherited from class org.objectweb.cjdbc.controller.cache.AbstractRequestCache |
getPendingQueryTimeout, setParsingGranularity, setPendingQueryTimeout |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private java.util.Hashtable queries
private java.util.HashSet pendingQueries
private QueryCacheEntry lruHead
private QueryCacheEntry lruTail
private CacheDatabaseSchema cdbs
private java.util.Hashtable entriesForTransaction
private int cacheGrain
private CacheStatistics stats
| Constructor Detail |
public QueryCache(int cacheGranularity)
Cache instance.
cacheGranularity - an int value| Method Detail |
private void initQueryCache(int cacheGranularity)
throws CacheException
CacheExceptionpublic void setDatabaseSchema(DatabaseSchema dbs)
DatabaseSchema of the current virtual database.
setDatabaseSchema in class AbstractRequestCachedbs - a DatabaseSchema valueCacheDatabaseSchemapublic void mergeDatabaseSchema(DatabaseSchema dbs)
DatabaseSchema with the current one.
mergeDatabaseSchema in class AbstractRequestCachedbs - a DatabaseSchema valueCacheDatabaseSchema
public void addToCache(SelectRequest request,
java.sql.ResultSet result)
throws CacheException
addToCache in class AbstractRequestCacherequest - the requestresult - the result corresponding to the request
CacheException - if an error occurs
public QueryCacheEntry getFromCache(SelectRequest request,
boolean addToPendingQueries)
QueryCacheEntry is null if the request is not
present in the cache.
An invalid QueryCacheEntry may be returned (it means that the
result is null) but the already parsed query can be retrieved
from the cache entry.
getFromCache in class AbstractRequestCacherequest - an SQL select requestaddToPendingQueries - true if the request must be added
to the pending query list on a cache miss
QueryCacheEntry if found, else null
public void removeFromCache(SelectRequest request)
throws CacheException
removeFromCache in class AbstractRequestCacherequest - a SelectRequest
CacheException - if an error occurs
public void writeNotify(AbstractWriteRequest request)
throws CacheException
writeNotify in class AbstractRequestCacherequest - an AbstractRequest value
CacheException - if an error occurspublic void flushCache()
flushCache in class AbstractRequestCacheprotected void removeOldest()
public int getParsingGranularity()
getParsingGranularity in class AbstractRequestCacheAbstractRequestCache.setParsingGranularity(int)
public void commit(TransactionMarkerMetaData tm)
throws CacheException
commit in class AbstractRequestCachetm - the transaction marker metadata
CacheException - if an error occurs
public void rollback(TransactionMarkerMetaData tm)
throws CacheException
rollback in class AbstractRequestCachetm - the transaction marker metadata
CacheException - if an error occurspublic java.lang.String getXmlInformation()
getXmlInformation in class AbstractRequestCacheString containing informationpublic java.lang.String getInformation()
getInformation in class AbstractRequestCacheString containing information
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||