|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jcs.auxiliary.disk.AbstractDiskCache
public abstract class AbstractDiskCache
Abstract class providing a base implementation of a disk cache, which can be easily extended to implement a disk cache for a specific perstistence mechanism.
When implementing the abstract methods note that while this base class handles most things, it does not acquire or release any locks. Implementations should do so as neccesary. This is mainly done to minimize the time speant in critical sections.
Error handling in this class needs to be addressed. Currently if an exception is thrown by the persistence mechanism, this class destroys the event queue. Should it also destory purgatory? Should it dispose itself?
| Field Summary | |
|---|---|
protected boolean |
alive
Indicates whether the cache is 'alive', defined as having been initialized, but not yet disposed. |
protected ICacheEventQueue |
cacheEventQueue
The CacheEventQueue where changes will be queued for asynchronous updating of the persistent storage. |
protected java.lang.String |
cacheName
Every cache will have a name, subclasses must set this when they are initialized. |
protected java.util.Map |
purgatory
Map where elements are stored between being added to this cache and actually spooled to disk. |
protected int |
purgHits
DEBUG: Keeps a count of the number of purgatory hits for debug messages |
| Fields inherited from interface org.apache.jcs.engine.behavior.ICacheType |
|---|
CACHE_HUB, DISK_CACHE, LATERAL_CACHE, REMOTE_CACHE |
| Constructor Summary | |
|---|---|
AbstractDiskCache(IDiskCacheAttributes attr)
Construc the abstract disk cache, create event queues and purgatory. |
|
| Method Summary | |
|---|---|
void |
dispose()
Adds a dispose request to the disk cache. |
protected abstract void |
doDispose()
Dispose of the persistent store. |
protected abstract ICacheElement |
doGet(java.io.Serializable key)
Get a value from the persistent store. |
protected abstract boolean |
doRemove(java.io.Serializable key)
Remove an object from the persistent store if found. |
protected abstract void |
doRemoveAll()
Remove all objects from the persistent store. |
protected abstract void |
doUpdate(ICacheElement element)
Add a cache element to the persistent store. |
ICacheElement |
get(java.io.Serializable key)
Check to see if the item is in purgatory. |
java.lang.String |
getCacheName()
Returns the cache name. |
int |
getCacheType()
Returns the cache type. |
abstract java.util.Set |
getGroupKeys(java.lang.String groupName)
The keys in a group. |
abstract int |
getSize()
Size cannot be determined without knowledge of the cache implementation, so subclasses will need to implement this method. |
IStats |
getStatistics()
Returns semi-structured data. |
java.lang.String |
getStats()
Gets basic stats for the abstract disk cache. |
int |
getStatus()
Returns the cache status. |
boolean |
remove(java.io.Serializable key)
Removes are not queued. |
void |
removeAll()
Removes all cached items from the cache. |
void |
update(ICacheElement cacheElement)
Adds the provided element to the cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.jcs.auxiliary.AuxiliaryCache |
|---|
getAuxiliaryCacheAttributes |
| Field Detail |
|---|
protected java.util.Map purgatory
If the elements are pulled into the memory cache while the are still in purgatory, writing to disk can be cancelled.
protected ICacheEventQueue cacheEventQueue
protected boolean alive
protected java.lang.String cacheName
protected int purgHits
| Constructor Detail |
|---|
public AbstractDiskCache(IDiskCacheAttributes attr)
attr - | Method Detail |
|---|
public final void update(ICacheElement cacheElement)
throws java.io.IOException
An update results in a put event being created. The put event will call the handlePut method defined here. The handlePut method calls the implemented doPut on the child.
update in interface AuxiliaryCacheupdate in interface ICachecacheElement -
java.io.IOExceptionICache.update(org.apache.jcs.engine.behavior.ICacheElement)public final ICacheElement get(java.io.Serializable key)
get in interface AuxiliaryCacheget in interface ICachekey -
AuxiliaryCache.get(java.io.Serializable)public abstract java.util.Set getGroupKeys(java.lang.String groupName)
(non-Javadoc)
getGroupKeys in interface AuxiliaryCacheAuxiliaryCache.getGroupKeys(java.lang.String)public final boolean remove(java.io.Serializable key)
remove in interface AuxiliaryCacheremove in interface ICachekey -
ICache.remove(java.io.Serializable)public final void removeAll()
AuxiliaryCache
removeAll in interface AuxiliaryCacheremoveAll in interface ICacheICache.removeAll()public final void dispose()
Disposal proceeds in several steps.
dispose in interface AuxiliaryCachedispose in interface ICachepublic java.lang.String getCacheName()
AuxiliaryCache
getCacheName in interface AuxiliaryCachegetCacheName in interface ICacheICache.getCacheName()public java.lang.String getStats()
getStats in interface ICachepublic IStats getStatistics()
getStatistics in interface AuxiliaryCacheAuxiliaryCache.getStatistics()public int getStatus()
AuxiliaryCache
getStatus in interface AuxiliaryCachegetStatus in interface ICacheICache.getStatus()public abstract int getSize()
getSize in interface AuxiliaryCachegetSize in interface ICacheICache.getSize()public int getCacheType()
ICacheType
getCacheType in interface ICacheTypeICacheType.getCacheType()protected abstract ICacheElement doGet(java.io.Serializable key)
key - Key to locate value for.
protected abstract void doUpdate(ICacheElement element)
element - protected abstract boolean doRemove(java.io.Serializable key)
key - Key of object to remove.
protected abstract void doRemoveAll()
protected abstract void doDispose()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||