|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jcs.auxiliary.disk.AbstractDiskCache
org.apache.jcs.auxiliary.disk.jdbc.JDBCDiskCache
public class JDBCDiskCache
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 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.
Field Summary |
---|
Fields inherited from class org.apache.jcs.auxiliary.disk.AbstractDiskCache |
---|
alive, cacheEventQueue, cacheName, purgatory, purgHits |
Fields inherited from interface org.apache.jcs.engine.behavior.ICacheType |
---|
CACHE_HUB, DISK_CACHE, LATERAL_CACHE, REMOTE_CACHE |
Constructor Summary | |
---|---|
JDBCDiskCache(JDBCDiskCacheAttributes cattr,
TableState tableState)
Constructs a JDBC Disk Cache for the provided cache attributes. |
Method Summary | |
---|---|
protected int |
deleteExpired()
Removed the expired. |
void |
doDispose()
Shuts down the pool |
protected boolean |
doesElementExist(ICacheElement ce)
Does an element exist for this key? |
ICacheElement |
doGet(java.io.Serializable key)
Queries the database for the value. |
boolean |
doRemove(java.io.Serializable key)
Returns true if the removal was succesful; or false if there is nothing to remove. |
void |
doRemoveAll()
This should remove all elements. |
void |
doUpdate(ICacheElement ce)
Add a cache element to the persistent store. |
AuxiliaryCacheAttributes |
getAuxiliaryCacheAttributes()
This returns the generic attributes for an auxiliary cache. |
IElementSerializer |
getElementSerializer()
|
java.util.Set |
getGroupKeys(java.lang.String groupName)
The keys in a group. |
protected JDBCDiskCacheAttributes |
getJdbcDiskCacheAttributes()
|
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 void |
initializePoolAccess(JDBCDiskCacheAttributes cattr)
Registers the driver and creates a poolAccess class. |
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)
|
protected void |
setJdbcDiskCacheAttributes(JDBCDiskCacheAttributes jdbcDiskCacheAttributes)
|
void |
setTableState(TableState tableState)
|
java.lang.String |
toString()
For debugging. |
Methods inherited from class org.apache.jcs.auxiliary.disk.AbstractDiskCache |
---|
dispose, get, getCacheName, getCacheType, getStats, getStatus, remove, removeAll, update |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JDBCDiskCache(JDBCDiskCacheAttributes cattr, TableState tableState)
cattr
- tableState
- Method Detail |
---|
protected void initializePoolAccess(JDBCDiskCacheAttributes cattr)
cattr
- public void doUpdate(ICacheElement ce)
AbstractDiskCache
doUpdate
in class AbstractDiskCache
protected boolean doesElementExist(ICacheElement ce)
ce
-
public ICacheElement doGet(java.io.Serializable key)
doGet
in class AbstractDiskCache
key
- Key to locate value for.
AbstractDiskCache.doGet(java.io.Serializable)
public boolean doRemove(java.io.Serializable key)
doRemove
in class AbstractDiskCache
key
-
public void doRemoveAll()
doRemoveAll
in class AbstractDiskCache
protected int deleteExpired()
public void reset()
public void doDispose()
doDispose
in class AbstractDiskCache
public int getSize()
getSize
in interface AuxiliaryCache
getSize
in interface ICache
getSize
in class AbstractDiskCache
ICache.getSize()
protected byte[] serialize(java.io.Serializable obj) throws java.io.IOException
obj
-
java.io.IOException
public java.util.Set getGroupKeys(java.lang.String groupName)
AbstractDiskCache
(non-Javadoc)
getGroupKeys
in interface AuxiliaryCache
getGroupKeys
in class AbstractDiskCache
groupName
-
AuxiliaryCache.getGroupKeys(java.lang.String)
public void setElementSerializer(IElementSerializer elementSerializer)
elementSerializer
- The elementSerializer to set.public IElementSerializer getElementSerializer()
protected void setJdbcDiskCacheAttributes(JDBCDiskCacheAttributes jdbcDiskCacheAttributes)
jdbcDiskCacheAttributes
- The jdbcDiskCacheAttributes to set.protected JDBCDiskCacheAttributes getJdbcDiskCacheAttributes()
public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
AuxiliaryCache
public IStats getStatistics()
getStatistics
in interface AuxiliaryCache
getStatistics
in class AbstractDiskCache
AuxiliaryCache.getStatistics()
protected java.lang.String getTableName()
public void setTableState(TableState tableState)
tableState
- The tableState to set.public TableState getTableState()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |