public class JDBCDiskCache extends AbstractDiskCache
It expects a table created by the following script. The table name is configurable.
drop TABLE JCS_STORE;
CREATE TABLE JCS_STORE
(
CACHE_KEY VARCHAR(250) NOT NULL,
REGION VARCHAR(250) NOT NULL,
ELEMENT BLOB,
CREATE_TIME DATE,
CREATE_TIME_SECONDS BIGINT,
MAX_LIFE_SECONDS BIGINT,
SYSTEM_EXPIRE_TIME_SECONDS BIGINT,
IS_ETERNAL CHAR(1),
PRIMARY KEY (CACHE_KEY, REGION)
);
The cleanup thread will delete non eternal items where (now - create time) > max life seconds * 1000
To speed up the deletion the SYSTEM_EXPIRE_TIME_SECONDS is used instead. It is recommended that an index be created on this column is you will have over a million records.
alive, cacheEventQueue, cacheName, purgatory, purgHitscacheEventLogger, keyMatcherCACHE_HUB, DISK_CACHE, LATERAL_CACHE, REMOTE_CACHE| Constructor and Description |
|---|
JDBCDiskCache(JDBCDiskCacheAttributes cattr,
TableState tableState,
ICompositeCacheManager compositeCacheManager)
Constructs a JDBC Disk Cache for the provided cache attributes.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
constructLikeParameterFromPattern(java.lang.String pattern) |
protected int |
deleteExpired()
Removed the expired.
|
protected boolean |
doesElementExist(ICacheElement ce)
Does an element exist for this key?
|
AuxiliaryCacheAttributes |
getAuxiliaryCacheAttributes()
This returns the generic attributes for an auxiliary cache.
|
protected java.lang.String |
getDiskLocation()
This is used by the event logging.
|
IElementSerializer |
getElementSerializer()
Allows it to be injected.
|
java.util.Set |
getGroupKeys(java.lang.String groupName)
The keys in a group.
|
protected JDBCDiskCacheAttributes |
getJdbcDiskCacheAttributes() |
JDBCDiskCachePoolAccess |
getPoolAccess()
Public so managers can access it.
|
int |
getSize()
Returns the current cache size.
|
IStats |
getStatistics()
Extends the parent stats.
|
protected java.lang.String |
getTableName()
Returns the name of the table.
|
TableState |
getTableState() |
protected JDBCDiskCachePoolAccess |
initializePoolAccess(JDBCDiskCacheAttributes cattr,
ICompositeCacheManager compositeCacheManager)
Registers the driver and creates a poolAccess class.
|
void |
processDispose()
Shuts down the pool
|
protected ICacheElement |
processGet(java.io.Serializable key)
Queries the database for the value.
|
protected java.util.Map |
processGetMatching(java.lang.String pattern)
This will run a like query.
|
protected boolean |
processRemove(java.io.Serializable key)
Returns true if the removal was successful; or false if there is nothing to remove.
|
protected void |
processRemoveAll()
This should remove all elements.
|
protected void |
processUpdate(ICacheElement ce)
Inserts or updates.
|
void |
reset()
Typically this is used to handle errors by last resort, force content update, or removeall
|
protected byte[] |
serialize(java.io.Serializable obj)
Returns the serialized form of the given object in a byte array.
|
void |
setElementSerializer(IElementSerializer elementSerializer)
Allows you to inject a custom serializer.
|
protected void |
setJdbcDiskCacheAttributes(JDBCDiskCacheAttributes jdbcDiskCacheAttributes) |
protected void |
setPoolAccess(JDBCDiskCachePoolAccess poolAccess) |
void |
setTableState(TableState tableState) |
java.lang.String |
toString()
For debugging.
|
dispose, doDispose, doGet, doGetMatching, doRemove, doRemoveAll, doUpdate, get, getCacheName, getCacheType, getEventLoggingExtraInfo, getMatching, getStats, getStatus, processGetMultiple, remove, removeAll, updatedisposeWithEventLogging, getMatchingWithEventLogging, getMultiple, getMultipleWithEventLogging, getWithEventLogging, removeAllWithEventLogging, removeWithEventLogging, updateWithEventLoggingcreateICacheEvent, createICacheEvent, getCacheEventLogger, getKeyMatcher, logApplicationEvent, logError, logICacheEvent, setCacheEventLogger, setKeyMatcherclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsetCacheEventLoggergetMultiple, setKeyMatcherpublic JDBCDiskCache(JDBCDiskCacheAttributes cattr, TableState tableState, ICompositeCacheManager compositeCacheManager)
cattr - tableState - compositeCacheManager - protected JDBCDiskCachePoolAccess initializePoolAccess(JDBCDiskCacheAttributes cattr, ICompositeCacheManager compositeCacheManager)
cattr - compositeCacheManager - protected void processUpdate(ICacheElement ce)
processUpdate in class AbstractAuxiliaryCacheEventLoggingce - protected boolean doesElementExist(ICacheElement ce)
ce - protected ICacheElement processGet(java.io.Serializable key)
processGet in class AbstractAuxiliaryCacheEventLoggingkey - AbstractDiskCache.doGet(java.io.Serializable)protected java.util.Map processGetMatching(java.lang.String pattern)
processGetMatching in class AbstractAuxiliaryCacheEventLoggingpattern - public java.lang.String constructLikeParameterFromPattern(java.lang.String pattern)
pattern - protected boolean processRemove(java.io.Serializable key)
processRemove in class AbstractAuxiliaryCacheEventLoggingkey - protected void processRemoveAll()
processRemoveAll in class AbstractAuxiliaryCacheEventLoggingprotected int deleteExpired()
public void reset()
public void processDispose()
processDispose in class AbstractAuxiliaryCacheEventLoggingpublic int getSize()
getSize in interface ICachegetSize in class AbstractDiskCacheICache.getSize()protected byte[] serialize(java.io.Serializable obj)
throws java.io.IOException
obj - java.io.IOExceptionpublic java.util.Set getGroupKeys(java.lang.String groupName)
AbstractDiskCache(non-Javadoc)
getGroupKeys in interface AuxiliaryCachegetGroupKeys in class AbstractDiskCachegroupName - AuxiliaryCache.getGroupKeys(java.lang.String)public void setElementSerializer(IElementSerializer elementSerializer)
AbstractAuxiliaryCacheDoes not allow you to set it to null.
setElementSerializer in interface AuxiliaryCachesetElementSerializer in class AbstractAuxiliaryCacheelementSerializer - The elementSerializer to set.public IElementSerializer getElementSerializer()
AbstractAuxiliaryCachegetElementSerializer in class AbstractAuxiliaryCacheprotected void setJdbcDiskCacheAttributes(JDBCDiskCacheAttributes jdbcDiskCacheAttributes)
jdbcDiskCacheAttributes - The jdbcDiskCacheAttributes to set.protected JDBCDiskCacheAttributes getJdbcDiskCacheAttributes()
public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
AuxiliaryCachepublic IStats getStatistics()
getStatistics in interface AuxiliaryCachegetStatistics in class AbstractDiskCacheAuxiliaryCache.getStatistics()protected java.lang.String getTableName()
public void setTableState(TableState tableState)
tableState - The tableState to set.public TableState getTableState()
protected java.lang.String getDiskLocation()
getDiskLocation in class AbstractDiskCacheprotected void setPoolAccess(JDBCDiskCachePoolAccess poolAccess)
poolAccess - the poolAccess to setpublic JDBCDiskCachePoolAccess getPoolAccess()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2002-2013 Apache Software Foundation. All Rights Reserved.