Class AbstractDiskCache<K,V> 
java.lang.Object
org.apache.commons.jcs3.auxiliary.AbstractAuxiliaryCache<K,V>
 
org.apache.commons.jcs3.auxiliary.AbstractAuxiliaryCacheEventLogging<K,V>
 
org.apache.commons.jcs3.auxiliary.disk.AbstractDiskCache<K,V> 
- All Implemented Interfaces:
- AuxiliaryCache<K,,- V> - ICache<K,,- V> - ICacheType
- Direct Known Subclasses:
- BlockDiskCache,- IndexedDiskCache,- JDBCDiskCache
Abstract class providing a base implementation of a disk cache, which can be easily extended to
 implement a disk cache for a specific persistence 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 necessary. This is mainly
 done to minimize the time spent 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 destroy purgatory?
 Should it dispose itself?
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classCache that implements the CacheListener interface, and calls appropriate methods in its parent class.Nested classes/interfaces inherited from interface org.apache.commons.jcs3.engine.behavior.ICacheTypeICacheType.CacheType
- 
Field SummaryFields inherited from interface org.apache.commons.jcs3.engine.behavior.ICacheNAME_COMPONENT_DELIMITER
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedConstruct the abstract disk cache, create event queues and purgatory.
- 
Method SummaryModifier and TypeMethodDescriptionfinal voiddispose()Adds a dispose request to the disk cache.protected final voidDispose of the persistent store.protected final ICacheElement<K,V> Get a value from the persistent store.protected final Map<K,ICacheElement<K, V>> doGetMatching(String pattern) Get a value from the persistent store.protected final booleanRemove an object from the persistent store if found.protected final voidRemove all objects from the persistent store.protected final voiddoUpdate(ICacheElement<K, V> cacheElement) Add a cache element to the persistent store.final ICacheElement<K,V> Check to see if the item is in purgatory.Returns the cache name.Returns the cache type.protected abstract StringThis is used by the event logging.Gets the extra info for the event log.The keys in the cache.Map<K,ICacheElement<K, V>> getMatching(String pattern) Gets items from the cache matching the given pattern.abstract intgetSize()Size cannot be determined without knowledge of the cache implementation, so subclasses will need to implement this method.Returns semi-structured data.getStats()Gets basic stats for the abstract disk cache.Returns the cache status.booleanisAlive()final booleanRemoves are not queued.final voidRemoves all from the region.voidsetAlive(boolean alive) final voidupdate(ICacheElement<K, V> cacheElement) Adds the provided element to the cache.Methods inherited from class org.apache.commons.jcs3.auxiliary.AbstractAuxiliaryCacheEventLoggingdisposeWithEventLogging, getMatchingWithEventLogging, getMultiple, getMultipleWithEventLogging, getWithEventLogging, processDispose, processGet, processGetMatching, processRemove, processRemoveAll, processUpdate, removeAllWithEventLogging, removeWithEventLogging, updateWithEventLoggingMethods inherited from class org.apache.commons.jcs3.auxiliary.AbstractAuxiliaryCachecreateICacheEvent, createICacheEvent, getCacheEventLogger, getElementSerializer, getKeyMatcher, logApplicationEvent, logError, logICacheEvent, processGetMultiple, setCacheEventLogger, setElementSerializer, setKeyMatcherMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.jcs3.auxiliary.AuxiliaryCachegetAuxiliaryCacheAttributes
- 
Constructor Details- 
AbstractDiskCacheConstruct the abstract disk cache, create event queues and purgatory. Child classes should set the alive flag to true after they are initialized.- Parameters:
- attr-
 
 
- 
- 
Method Details- 
isAlive- Returns:
- true if the cache is alive
 
- 
setAlive- Parameters:
- alive- set the alive status
 
- 
updateAdds the provided element to the cache. Element will be added to purgatory, and then queued for later writing to the serialized storage mechanism. 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.- Specified by:
- updatein interface- ICache<K,- V> 
- Overrides:
- updatein class- AbstractAuxiliaryCacheEventLogging<K,- V> 
- Parameters:
- cacheElement-
- Throws:
- IOException
- See Also:
 
- 
getCheck to see if the item is in purgatory. If so, return it. If not, check to see if we have it on disk.
- 
getMatchingGets items from the cache matching the given pattern. Items from memory will replace those from remote sources. This only works with string keys. It's too expensive to do a toString on every key. Auxiliaries will do their best to handle simple expressions. For instance, the JDBC disk cache will convert * to % and . to _- Specified by:
- getMatchingin interface- ICache<K,- V> 
- Overrides:
- getMatchingin class- AbstractAuxiliaryCacheEventLogging<K,- V> 
- Parameters:
- pattern-
- Returns:
- a map of K key to ICacheElement<K, V> element, or an empty map if there is no data matching the pattern.
- Throws:
- IOException
 
- 
getKeySetThe keys in the cache.- Returns:
- a set of the key type TODO This should probably be done in chunks with a range passed in. This will be a problem if someone puts a 1,000,000 or so items in a region.
- Throws:
- IOException- if access to the auxiliary cache fails
- See Also:
 
- 
removeRemoves are not queued. A call to remove is immediate.- Specified by:
- removein interface- ICache<K,- V> 
- Overrides:
- removein class- AbstractAuxiliaryCacheEventLogging<K,- V> 
- Parameters:
- key-
- Returns:
- whether the item was present to be removed.
- Throws:
- IOException
- See Also:
 
- 
removeAllDescription copied from class:AbstractAuxiliaryCacheEventLoggingRemoves all from the region. Wraps the removeAll in event logs.- Specified by:
- removeAllin interface- ICache<K,- V> 
- Overrides:
- removeAllin class- AbstractAuxiliaryCacheEventLogging<K,- V> 
- Throws:
- IOException
- See Also:
 
- 
disposeAdds a dispose request to the disk cache. Disposal proceeds in several steps.- Prior to this call the Composite cache dumped the memory into the disk cache. If it is large then we need to wait for the event queue to finish.
- Wait until the event queue is empty of until the configured ShutdownSpoolTimeLimit is reached.
- Call doDispose on the concrete impl.
 - Specified by:
- disposein interface- ICache<K,- V> 
- Overrides:
- disposein class- AbstractAuxiliaryCacheEventLogging<K,- V> 
- Throws:
- IOException
 
- 
getCacheNameDescription copied from interface:ICacheReturns the cache name.- Returns:
- the region name.
- See Also:
 
- 
getStatsGets basic stats for the abstract disk cache.- Returns:
- String
 
- 
getStatisticsReturns semi-structured data.- Returns:
- the historical and statistical data for a region's auxiliary cache.
- See Also:
 
- 
getStatusDescription copied from interface:ICacheReturns the cache status.- Returns:
- the status -- alive or disposed from CacheConstants
- See Also:
 
- 
getSizeSize cannot be determined without knowledge of the cache implementation, so subclasses will need to implement this method.- Returns:
- the number of items.
- See Also:
 
- 
getCacheTypeDescription copied from interface:ICacheTypeReturns the cache type.- Returns:
- Always returns DISK_CACHE since subclasses should all be of that type.
- See Also:
 
- 
doGetGet a value from the persistent store. Before the event logging layer, the subclasses implemented the do* methods. Now the do* methods call the *EventLogging method on the super. The *WithEventLogging methods call the abstract process* methods. The children implement the process methods.- Parameters:
- key- Key to locate value for.
- Returns:
- An object matching key, or null.
- Throws:
- IOException
 
- 
doGetMatchingGet a value from the persistent store. Before the event logging layer, the subclasses implemented the do* methods. Now the do* methods call the *EventLogging method on the super. The *WithEventLogging methods call the abstract process* methods. The children implement the process methods.- Parameters:
- pattern- Used to match keys.
- Returns:
- A map of matches..
- Throws:
- IOException
 
- 
doUpdateAdd a cache element to the persistent store. Before the event logging layer, the subclasses implemented the do* methods. Now the do* methods call the *EventLogging method on the super. The *WithEventLogging methods call the abstract process* methods. The children implement the process methods.- Parameters:
- cacheElement-
- Throws:
- IOException
 
- 
doRemoveRemove an object from the persistent store if found. Before the event logging layer, the subclasses implemented the do* methods. Now the do* methods call the *EventLogging method on the super. The *WithEventLogging methods call the abstract process* methods. The children implement the process methods.- Parameters:
- key- Key of object to remove.
- Returns:
- whether or no the item was present when removed
- Throws:
- IOException
 
- 
doRemoveAllRemove all objects from the persistent store. Before the event logging layer, the subclasses implemented the do* methods. Now the do* methods call the *EventLogging method on the super. The *WithEventLogging methods call the abstract process* methods. The children implement the process methods.- Throws:
- IOException
 
- 
doDisposeDispose of the persistent store. Note that disposal of purgatory and setting alive to false does NOT need to be done by this method. Before the event logging layer, the subclasses implemented the do* methods. Now the do* methods call the *EventLogging method on the super. The *WithEventLogging methods call the abstract process* methods. The children implement the process methods.- Throws:
- IOException
 
- 
getEventLoggingExtraInfoGets the extra info for the event log.- Specified by:
- getEventLoggingExtraInfoin class- AbstractAuxiliaryCache<K,- V> 
- Returns:
- disk location
 
- 
getDiskLocationThis is used by the event logging.- Returns:
- the location of the disk, either path or ip.
 
 
-