Class BlockDiskCache<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>
 
org.apache.commons.jcs3.auxiliary.disk.block.BlockDiskCache<K,V> 
- All Implemented Interfaces:
- AuxiliaryCache<K,,- V> - ICache<K,,- V> - ICacheType,- IRequireScheduler
There is one BlockDiskCache per region. It manages the key and data store.
- 
Nested Class SummaryNested classes/interfaces inherited from class org.apache.commons.jcs3.auxiliary.disk.AbstractDiskCacheAbstractDiskCache.MyCacheListenerNested 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 SummaryConstructorsConstructorDescriptionBlockDiskCache(BlockDiskCacheAttributes cacheAttributes) Constructs the BlockDisk after setting up the root directory.BlockDiskCache(BlockDiskCacheAttributes cacheAttributes, IElementSerializer elementSerializer) Constructs the BlockDisk after setting up the root directory.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidInternal method that handles the disposal.protected voidfreeBlocks(int[] blocksToFree) Add these blocks to the emptyBlock list.Returns the attributes.protected StringThis is used by the event logging.Return the keys in this cache.intgetSize()Returns the number of keys.Returns info about the disk cache.voidDispose of the disk cache in a background thread.protected ICacheElement<K,V> processGet(K key) Gets the ICacheElement<K, V> for the key if it is in the cache.Map<K,ICacheElement<K, V>> processGetMatching(String pattern) Gets matching items from the cache.protected booleanprocessRemove(K key) Returns true if the removal was successful; or false if there is nothing to remove.protected voidResets the keyfile, the disk file, and the memory key map.protected voidprocessUpdate(ICacheElement<K, V> element) Writes an element to disk.voidsetScheduledExecutorService(ScheduledExecutorService scheduledExecutor) Inject an instance of a central ScheduledExecutorServiceprotected booleanWe need to verify that the file on disk uses the same block size and that the file is the proper size.Methods inherited from class org.apache.commons.jcs3.auxiliary.disk.AbstractDiskCachedispose, doDispose, doGet, doGetMatching, doRemove, doRemoveAll, doUpdate, get, getCacheName, getCacheType, getEventLoggingExtraInfo, getMatching, getStats, getStatus, isAlive, remove, removeAll, setAlive, updateMethods inherited from class org.apache.commons.jcs3.auxiliary.AbstractAuxiliaryCacheEventLoggingdisposeWithEventLogging, getMatchingWithEventLogging, getMultiple, getMultipleWithEventLogging, getWithEventLogging, removeAllWithEventLogging, removeWithEventLogging, updateWithEventLoggingMethods inherited from class org.apache.commons.jcs3.auxiliary.AbstractAuxiliaryCachecreateICacheEvent, createICacheEvent, getCacheEventLogger, getElementSerializer, getKeyMatcher, logApplicationEvent, logError, logICacheEvent, processGetMultiple, setCacheEventLogger, setElementSerializer, setKeyMatcher
- 
Constructor Details- 
BlockDiskCacheConstructs the BlockDisk after setting up the root directory.- Parameters:
- cacheAttributes-
 
- 
BlockDiskCachepublic BlockDiskCache(BlockDiskCacheAttributes cacheAttributes, IElementSerializer elementSerializer) Constructs the BlockDisk after setting up the root directory.- Parameters:
- cacheAttributes-
- elementSerializer- used if supplied, the super's super will not set a null
 
 
- 
- 
Method Details- 
setScheduledExecutorServiceDescription copied from interface:IRequireSchedulerInject an instance of a central ScheduledExecutorService- Specified by:
- setScheduledExecutorServicein interface- IRequireScheduler
- See Also:
 
- 
verifyDiskWe need to verify that the file on disk uses the same block size and that the file is the proper size.- Returns:
- true if it looks ok
 
- 
getKeySetReturn the keys in this cache.- Specified by:
- getKeySetin interface- AuxiliaryCache<K,- V> 
- Specified by:
- getKeySetin class- AbstractDiskCache<K,- V> 
- 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:
 
- 
processGetMatchingGets matching items from the cache.- Specified by:
- processGetMatchingin 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 in cache matching keys
 
- 
getSizeReturns the number of keys.(non-Javadoc) 
- 
processGetGets the ICacheElement<K, V> for the key if it is in the cache. The program flow is as follows:- Make sure the disk cache is alive.
- Get a read lock.
- See if the key is in the key store.
- If we found a key, ask the BlockDisk for the object at the blocks..
- Release the lock.
 - Specified by:
- processGetin class- AbstractAuxiliaryCacheEventLogging<K,- V> 
- Parameters:
- key-
- Returns:
- ICacheElement
- See Also:
 
- 
processUpdateWrites an element to disk. The program flow is as follows:- Acquire write lock.
- See id an item exists for this key.
- If an item already exists, add its blocks to the remove list.
- Have the Block disk write the item.
- Create a descriptor and add it to the key map.
- Release the write lock.
 - Specified by:
- processUpdatein class- AbstractAuxiliaryCacheEventLogging<K,- V> 
- Parameters:
- element-
- See Also:
 
- 
processRemoveReturns true if the removal was successful; or false if there is nothing to remove. Current implementation always result in a disk orphan.- Specified by:
- processRemovein class- AbstractAuxiliaryCacheEventLogging<K,- V> 
- Parameters:
- key-
- Returns:
- true if removed anything
- See Also:
 
- 
processRemoveAllResets the keyfile, the disk file, and the memory key map.- Specified by:
- processRemoveAllin class- AbstractAuxiliaryCacheEventLogging<K,- V> 
- See Also:
 
- 
processDisposeDispose of the disk cache in a background thread. Joins against this thread to put a cap on the disposal time.TODO make dispose window configurable. - Specified by:
- processDisposein class- AbstractAuxiliaryCacheEventLogging<K,- V> 
 
- 
disposeInternalInternal method that handles the disposal.
- 
getAuxiliaryCacheAttributesReturns the attributes.- Specified by:
- getAuxiliaryCacheAttributesin interface- AuxiliaryCache<K,- V> 
- Returns:
- the attributes for the auxiliary cache
- See Also:
 
- 
freeBlocksAdd these blocks to the emptyBlock list.- Parameters:
- blocksToFree-
 
- 
getStatisticsReturns info about the disk cache.- Specified by:
- getStatisticsin interface- AuxiliaryCache<K,- V> 
- Overrides:
- getStatisticsin class- AbstractDiskCache<K,- V> 
- Returns:
- the historical and statistical data for a region's auxiliary cache.
- See Also:
 
- 
getDiskLocationThis is used by the event logging.- Specified by:
- getDiskLocationin class- AbstractDiskCache<K,- V> 
- Returns:
- the location of the disk, either path or ip.
 
 
-