|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.objectweb.cjdbc.controller.cache.result.AbstractResultCache
This class defines the minimal functionnalities that a request cache must provide.
Only read requests (SELECT
s) can be cached, there is no
sense to cache writes as they do not provide any result to cache. However,
the cache must be notified of the write queries in order to maintain cache
coherency.
Field Summary | |
protected static Trace |
logger
Logger instance. |
protected int |
parsingGranularity
Parsing granularity. |
Fields inherited from interface org.objectweb.cjdbc.common.xml.XmlComponent |
DOCTYPE_CONTROLLER, DOCTYPE_DB, XML_VERSION |
Constructor Summary | |
AbstractResultCache()
|
Method Summary | |
abstract void |
addCachingRule(ResultCacheRule rule)
Add precise management and configuration of the cache behavior. |
abstract void |
addToCache(SelectRequest request,
ControllerResultSet result)
Adds an entry request/reply to the cache. |
abstract void |
commit(long transactionId)
Commit a transaction given its id. |
abstract void |
flushCache()
Removes all entries from the cache. |
abstract java.lang.String[][] |
getCacheData()
Returns the content of the cache as displayable array of array of string |
abstract long |
getCacheSize()
Returns number of entries in the cache |
abstract CacheStatistics |
getCacheStatistics()
Returns pointer to the stats collector |
abstract java.lang.String[][] |
getCacheStatsData()
Returns a bunch of stats collected by the cache, such as cache hits. |
abstract ResultCacheRule |
getDefaultRule()
Return the default cache rule |
abstract AbstractResultCacheEntry |
getFromCache(SelectRequest request,
boolean addToPendingQueries)
Gets the result to the given request from the cache. |
int |
getParsingGranularity()
Gets the needed query parsing granularity. |
java.lang.String |
getXml()
Get xml formatted representation of this cjdbc component |
protected abstract java.lang.String |
getXmlImpl()
Gets information about the request cache in xml |
abstract boolean |
isUpdateNecessary(UpdateRequest request)
Returns true if the cache does not contain the values that are given in the update statement. |
void |
mergeDatabaseSchema(DatabaseSchema dbs)
Merge the given DatabaseSchema with the current one. |
abstract void |
removeFromCache(SelectRequest request)
Removes an entry from the cache (both request and reply are dropped). |
abstract void |
removeFromPendingQueries(SelectRequest request)
Removes an entry from the pending query list. |
abstract void |
rollback(long transactionId)
Rollback a transaction given its id. |
void |
setDatabaseSchema(DatabaseSchema dbs)
Sets the DatabaseSchema of the current virtual database. |
abstract void |
setDefaultRule(ResultCacheRule defaultRule)
Set the default query rule |
void |
setParsingGranularity(int parsingGranularity)
Sets the needed query parsing granularity. |
abstract void |
shutdown()
Shutdown the result cache and all its threads. |
abstract void |
writeNotify(AbstractWriteRequest request)
Notifies the cache that the given write request has been issued, so that cache coherency can be maintained. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int parsingGranularity
ParsingGranularities.NO_PARSING
.
protected static Trace logger
Constructor Detail |
public AbstractResultCache()
Method Detail |
public int getParsingGranularity()
setParsingGranularity(int)
public void setParsingGranularity(int parsingGranularity)
parsingGranularity
- the query parsing granularity to setgetParsingGranularity()
public void setDatabaseSchema(DatabaseSchema dbs)
DatabaseSchema
of the current virtual database.
dbs
- a DatabaseSchema
valueCacheDatabaseSchema
public void mergeDatabaseSchema(DatabaseSchema dbs)
DatabaseSchema
with the current one.
dbs
- a DatabaseSchema
valueCacheDatabaseSchema
public abstract void addCachingRule(ResultCacheRule rule)
rule
- of action for the cacheResultCacheRule
public abstract ResultCacheRule getDefaultRule()
public abstract void setDefaultRule(ResultCacheRule defaultRule)
defaultRule
- default rule to setpublic abstract void addToCache(SelectRequest request, ControllerResultSet result) throws CacheException
request
- the requestresult
- the result corresponding to the request
CacheException
- if an error occurspublic abstract AbstractResultCacheEntry getFromCache(SelectRequest request, boolean addToPendingQueries)
The returned AbstractResultCacheEntry
is null
if the request is not present in the cache.
An invalid CacheEntry
may be returned (it means that the
result is null
) but the already parsed query can be
retrieved from the cache entry.
request
- an SQL select requestaddToPendingQueries
- true if the request must be added to the pending
query list on a cache miss
AbstractResultCacheEntry
if found, else nullpublic abstract void removeFromCache(SelectRequest request)
request
- a SelectRequest
public abstract void removeFromPendingQueries(SelectRequest request)
request
- a SelectRequest
public abstract void shutdown()
public abstract void writeNotify(AbstractWriteRequest request) throws CacheException
request
- an AbstractWriteRequest
value
CacheException
- if an error occurspublic abstract boolean isUpdateNecessary(UpdateRequest request) throws CacheException
request
- the update request that needs to be executed
CacheException
- if an error occurspublic abstract void flushCache()
public abstract void commit(long transactionId) throws CacheException
transactionId
- the transaction id
CacheException
- if an error occurspublic abstract void rollback(long transactionId) throws CacheException
transactionId
- the transaction id
CacheException
- if an error occursprotected abstract java.lang.String getXmlImpl()
String
containing informationpublic java.lang.String getXml()
XmlComponent
getXml
in interface XmlComponent
XmlComponent.getXml()
public abstract java.lang.String[][] getCacheData() throws CacheException
CacheException
- if failspublic abstract java.lang.String[][] getCacheStatsData() throws CacheException
CacheException
- if fails to collect the data.public abstract CacheStatistics getCacheStatistics()
CacheStatistics
objectpublic abstract long getCacheSize()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |