|
|||||||||||
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.QueryCacheDB
This is a query cache implementation with tunable granularity.
Cache invalidation granularity can take on of the following values:
COLUMN_UNIQUE_INSERT_DB
: column granularity with
UNIQUE
queries and INSERT_DB
optimization. Same as
COLUMN_UNIQUE
except that queries are not invalidated on an
INSERT
, they are just marked dirty. When a dirty entry is
found, the INSERT_DB
is used to determine if the result is
still valid or not.COLUMN_UNIQUE_INSERT_DB_UNIQUE_UPDATE
:
TODO: complete javadoc
Field Summary | |
private int |
cacheGrain
|
private CacheDatabaseSchema |
cdbs
|
private java.sql.Connection |
conn
|
private int |
create
|
private int |
delete
|
private java.lang.String |
driver
|
private int |
drop
|
private int |
hits
|
private int |
insert
|
private QueryCacheEntry |
lruHead
|
private QueryCacheEntry |
lruTail
|
private java.lang.String |
password
|
private java.util.Hashtable |
queries
|
private int |
remove
|
private int |
select
|
private int |
unknown
|
private int |
update
|
private java.lang.String |
url
|
private java.lang.String |
user
|
Fields inherited from class org.objectweb.cjdbc.controller.cache.AbstractRequestCache |
logger, parsingGranularity, pendingQueryTimeout |
Constructor Summary | |
QueryCacheDB(int cacheGranularity,
java.lang.String driver,
java.lang.String url,
java.lang.String user,
java.lang.String password,
DatabaseSchema dbs)
Creates a new Cache instance and connect to the given cache
database. |
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. |
private void |
executeCacheDB(java.lang.String sql)
|
void |
flushCache()
Removes all entries from the cache. |
QueryCacheEntry |
getFromCache(SelectRequest sqlQuery,
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 in xml |
private void |
handleWrite(AbstractWriteRequest request)
This method maintains cache coherency upon a write request. |
private void |
initQueryCache(int cacheGranularity,
DatabaseSchema dbs)
|
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 |
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, mergeDatabaseSchema, setDatabaseSchema, setParsingGranularity, setPendingQueryTimeout |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.sql.Connection conn
private java.util.Hashtable queries
private QueryCacheEntry lruHead
private QueryCacheEntry lruTail
private CacheDatabaseSchema cdbs
private int select
private int hits
private int insert
private int update
private int delete
private int unknown
private int remove
private int create
private int drop
private java.lang.String user
private java.lang.String password
private java.lang.String url
private java.lang.String driver
private int cacheGrain
Constructor Detail |
public QueryCacheDB(int cacheGranularity, java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password, DatabaseSchema dbs)
Cache
instance and connect to the given cache
database.
cacheGranularity
- an int
valuedriver
- cache database driver classurl
- JDBC URL to access the cache databaseuser
- user name to use to access the cache databasepassword
- password to use to access the cache databasedbs
- the CacheDatabaseSchema
Method Detail |
public int getParsingGranularity()
getParsingGranularity
in class AbstractRequestCache
AbstractRequestCache.setParsingGranularity(int)
private void initQueryCache(int cacheGranularity, DatabaseSchema dbs) throws CacheException
CacheException
public void addToCache(SelectRequest request, java.sql.ResultSet result) throws CacheException
addToCache
in class AbstractRequestCache
request
- the requestresult
- the result corresponding to the request
CacheException
- if an error occurspublic QueryCacheEntry getFromCache(SelectRequest sqlQuery, 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 AbstractRequestCache
sqlQuery
- an SQL 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 AbstractRequestCache
request
- an SelectRequest
CacheException
- if an error occurspublic void writeNotify(AbstractWriteRequest request) throws CacheException
writeNotify
in class AbstractRequestCache
request
- an AbstractRequest
value
CacheException
- if an error occursprivate void handleWrite(AbstractWriteRequest request) throws CacheException
request
- an AbstractRequest
value
CacheException
- if an error occursprivate void executeCacheDB(java.lang.String sql)
public void flushCache()
flushCache
in class AbstractRequestCache
protected void removeOldest()
public void commit(TransactionMarkerMetaData tm) throws CacheException
commit
in class AbstractRequestCache
tm
- the transaction marker metadata
CacheException
- if an error occurspublic void rollback(TransactionMarkerMetaData tm) throws CacheException
rollback
in class AbstractRequestCache
tm
- the transaction marker metadata
CacheException
- if an error occurspublic java.lang.String getInformation()
getInformation
in class AbstractRequestCache
String
containing informationpublic java.lang.String getXmlInformation()
getXmlInformation
in class AbstractRequestCache
String
containing information, xml formatted.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |