|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jcs.auxiliary.AbstractAuxiliaryCache<K,V>
org.apache.jcs.auxiliary.AbstractAuxiliaryCacheEventLogging<K,V>
org.apache.jcs.auxiliary.disk.AbstractDiskCache<K,V>
org.apache.jcs.auxiliary.disk.jdbc.JDBCDiskCache<K,V>
public class JDBCDiskCache<K extends Serializable,V extends Serializable>
This is the jdbc disk cache plugin.
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 TIMESTAMP,
UPDATE_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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.apache.jcs.auxiliary.disk.AbstractDiskCache |
|---|
AbstractDiskCache.MyCacheListener |
| Nested classes/interfaces inherited from interface org.apache.jcs.engine.behavior.ICacheType |
|---|
ICacheType.CacheType |
| Field Summary |
|---|
| Fields inherited from class org.apache.jcs.auxiliary.disk.AbstractDiskCache |
|---|
alive, cacheEventQueue, cacheName, purgatory, purgHits, removeAllLock |
| Fields inherited from class org.apache.jcs.auxiliary.AbstractAuxiliaryCache |
|---|
cacheEventLogger, keyMatcher |
| Constructor Summary | |
|---|---|
JDBCDiskCache(JDBCDiskCacheAttributes cattr,
TableState tableState,
ICompositeCacheManager compositeCacheManager)
Constructs a JDBC Disk Cache for the provided cache attributes. |
|
| Method Summary | |
|---|---|
String |
constructLikeParameterFromPattern(String pattern)
|
protected int |
deleteExpired()
Removed the expired. |
protected boolean |
doesElementExist(ICacheElement<K,V> ce)
Does an element exist for this key? |
AuxiliaryCacheAttributes |
getAuxiliaryCacheAttributes()
This returns the generic attributes for an auxiliary cache. |
protected String |
getDiskLocation()
This is used by the event logging. |
IElementSerializer |
getElementSerializer()
Allows it to be injected. |
Set<K> |
getGroupKeys(String groupName)
The keys in a group. |
Set<String> |
getGroupNames()
The group names in the cache. |
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 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<K,V> |
processGet(K key)
Queries the database for the value. |
protected Map<K,ICacheElement<K,V>> |
processGetMatching(String pattern)
This will run a like query. |
protected boolean |
processRemove(K 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<K,V> ce)
Inserts or updates. |
void |
reset()
Typically this is used to handle errors by last resort, force content update, or removeall |
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)
|
String |
toString()
For debugging. |
| Methods inherited from class org.apache.jcs.auxiliary.disk.AbstractDiskCache |
|---|
dispose, doDispose, doGet, doGetMatching, doRemove, doRemoveAll, doUpdate, get, getCacheName, getCacheType, getEventLoggingExtraInfo, getMatching, getStats, getStatus, processGetMultiple, remove, removeAll, update |
| Methods inherited from class org.apache.jcs.auxiliary.AbstractAuxiliaryCacheEventLogging |
|---|
disposeWithEventLogging, getMatchingWithEventLogging, getMultiple, getMultipleWithEventLogging, getWithEventLogging, removeAllWithEventLogging, removeWithEventLogging, updateWithEventLogging |
| Methods inherited from class org.apache.jcs.auxiliary.AbstractAuxiliaryCache |
|---|
createICacheEvent, createICacheEvent, getCacheEventLogger, getKeyMatcher, logApplicationEvent, logError, logICacheEvent, setCacheEventLogger, setKeyMatcher |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.jcs.auxiliary.AuxiliaryCache |
|---|
setCacheEventLogger |
| Methods inherited from interface org.apache.jcs.engine.behavior.ICache |
|---|
getMultiple, setKeyMatcher |
| Constructor Detail |
|---|
public JDBCDiskCache(JDBCDiskCacheAttributes cattr,
TableState tableState,
ICompositeCacheManager compositeCacheManager)
cattr - tableState - compositeCacheManager - | Method Detail |
|---|
protected JDBCDiskCachePoolAccess initializePoolAccess(JDBCDiskCacheAttributes cattr,
ICompositeCacheManager compositeCacheManager)
cattr - compositeCacheManager -
protected void processUpdate(ICacheElement<K,V> ce)
processUpdate in class AbstractAuxiliaryCacheEventLogging<K extends Serializable,V extends Serializable>ce - protected boolean doesElementExist(ICacheElement<K,V> ce)
ce -
protected ICacheElement<K,V> processGet(K key)
processGet in class AbstractAuxiliaryCacheEventLogging<K extends Serializable,V extends Serializable>key -
AbstractDiskCache.doGet(java.io.Serializable)protected Map<K,ICacheElement<K,V>> processGetMatching(String pattern)
processGetMatching in class AbstractAuxiliaryCacheEventLogging<K extends Serializable,V extends Serializable>pattern -
public String constructLikeParameterFromPattern(String pattern)
pattern -
protected boolean processRemove(K key)
processRemove in class AbstractAuxiliaryCacheEventLogging<K extends Serializable,V extends Serializable>key -
protected void processRemoveAll()
processRemoveAll in class AbstractAuxiliaryCacheEventLogging<K extends Serializable,V extends Serializable>protected int deleteExpired()
public void reset()
public void processDispose()
processDispose in class AbstractAuxiliaryCacheEventLogging<K extends Serializable,V extends Serializable>public int getSize()
getSize in interface ICache<K extends Serializable,V extends Serializable>getSize in class AbstractDiskCache<K extends Serializable,V extends Serializable>ICache.getSize()public Set<K> getGroupKeys(String groupName)
AbstractDiskCache
getGroupKeys in interface AuxiliaryCache<K extends Serializable,V extends Serializable>getGroupKeys in class AbstractDiskCache<K extends Serializable,V extends Serializable>groupName -
AuxiliaryCache.getGroupKeys(java.lang.String)public Set<String> getGroupNames()
AbstractDiskCache
getGroupNames in interface AuxiliaryCache<K extends Serializable,V extends Serializable>getGroupNames in class AbstractDiskCache<K extends Serializable,V extends Serializable>AuxiliaryCache.getGroupNames()public void setElementSerializer(IElementSerializer elementSerializer)
AbstractAuxiliaryCacheDoes not allow you to set it to null.
setElementSerializer in interface AuxiliaryCache<K extends Serializable,V extends Serializable>setElementSerializer in class AbstractAuxiliaryCache<K extends Serializable,V extends Serializable>elementSerializer - The elementSerializer to set.public IElementSerializer getElementSerializer()
AbstractAuxiliaryCache
getElementSerializer in class AbstractAuxiliaryCache<K extends Serializable,V extends Serializable>protected void setJdbcDiskCacheAttributes(JDBCDiskCacheAttributes jdbcDiskCacheAttributes)
jdbcDiskCacheAttributes - The jdbcDiskCacheAttributes to set.protected JDBCDiskCacheAttributes getJdbcDiskCacheAttributes()
public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
AuxiliaryCache
public IStats getStatistics()
getStatistics in interface AuxiliaryCache<K extends Serializable,V extends Serializable>getStatistics in class AbstractDiskCache<K extends Serializable,V extends Serializable>AuxiliaryCache.getStatistics()protected String getTableName()
public void setTableState(TableState tableState)
tableState - The tableState to set.public TableState getTableState()
protected String getDiskLocation()
getDiskLocation in class AbstractDiskCache<K extends Serializable,V extends Serializable>protected void setPoolAccess(JDBCDiskCachePoolAccess poolAccess)
poolAccess - the poolAccess to setpublic JDBCDiskCachePoolAccess getPoolAccess()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||