Class AbstractMemoryCache<K,V> 
java.lang.Object
org.apache.commons.jcs3.engine.memory.AbstractMemoryCache<K,V> 
- All Implemented Interfaces:
- IMemoryCache<K,- V> 
- Direct Known Subclasses:
- AbstractDoubleLinkedListMemoryCache,- LHMLRUMemoryCache,- SoftReferenceMemoryCache
This base includes some common code for memory caches.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected intHow many to spool at a time.protected AtomicLongnumber of hitsprotected final Lockprotected Map<K,MemoryElementDescriptor<K, V>> Map where items are stored by key.protected AtomicLongnumber of missesprotected AtomicLongnumber of puts
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionabstract Map<K,MemoryElementDescriptor<K, V>> Children must implement this method.voiddispose()Prepares for shutdown.voiddumpMap()Dump the cache map for debugging.Get an item from the cache.Returns the CacheAttributes.Returns the cache (aka "region") name.Gets the cache hub / region that the MemoryCache is used byGet an Array of the keys for all elements in the memory cacheMap<K,ICacheElement<K, V>> getMultiple(Set<K> keys) Gets multiple items from the cache based on the given set of keys.Get an item from the cache without affecting its last access time or position.intgetSize()Returns the current cache size.Returns the historical and statistical data for a region's memory cache.voidinitialize(CompositeCache<K, V> hub) For post reflection creation initializationprotected abstract voidUpdate control structures after get (guarded by the lock)protected abstract voidRemoves all cached items from the cache control structures.protected abstract voidRemove element from control structure (guarded by the lock)booleanRemoves an item from the cache.voidRemoves all cached items from the cache.protected booleanremoveByGroup(K key) Remove all keys of the same group hierarchy.protected booleanremoveByHierarchy(K key) Remove all keys of the same name hierarchy.voidSets the CacheAttributes.abstract voidupdate(ICacheElement<K, V> ce) Puts an item to the cache.voidwaterfal(ICacheElement<K, V> ce) Puts an item to the cache.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.jcs3.engine.memory.behavior.IMemoryCachefreeElements
- 
Field Details- 
chunkSizeHow many to spool at a time.
- 
lock
- 
mapMap where items are stored by key. This is created by the concrete child class.
- 
hitCntnumber of hits
- 
missCntnumber of misses
- 
putCntnumber of puts
 
- 
- 
Constructor Details- 
AbstractMemoryCachepublic AbstractMemoryCache()
 
- 
- 
Method Details- 
initializeFor post reflection creation initialization- Specified by:
- initializein interface- IMemoryCache<K,- V> 
- Parameters:
- hub-
 
- 
createMapChildren must implement this method. A FIFO implementation may use a tree map. An LRU might use a hashtable. The map returned should be threadsafe.- Returns:
- a threadsafe Map
 
- 
getMultipleGets multiple items from the cache based on the given set of keys.- Specified by:
- getMultiplein interface- IMemoryCache<K,- V> 
- Parameters:
- keys-
- Returns:
- a map of K key to ICacheElement<K, V> element, or an empty map if there is no data in cache for any of these keys
- Throws:
- IOException
 
- 
getQuietGet an item from the cache without affecting its last access time or position. Not all memory cache implementations can get quietly.- Specified by:
- getQuietin interface- IMemoryCache<K,- V> 
- Parameters:
- key- Identifies item to find
- Returns:
- Element matching key if found, or null
- Throws:
- IOException
 
- 
updatePuts an item to the cache.- Specified by:
- updatein interface- IMemoryCache<K,- V> 
- Parameters:
- ce- Description of the Parameter
- Throws:
- IOException- Description of the Exception
 
- 
removeAllRemoves all cached items from the cache.- Specified by:
- removeAllin interface- IMemoryCache<K,- V> 
- Throws:
- IOException
 
- 
lockedRemoveAllRemoves all cached items from the cache control structures. (guarded by the lock)
- 
disposePrepares for shutdown. Reset statistics- Specified by:
- disposein interface- IMemoryCache<K,- V> 
- Throws:
- IOException
 
- 
getStatisticsDescription copied from interface:IMemoryCacheReturns the historical and statistical data for a region's memory cache.- Specified by:
- getStatisticsin interface- IMemoryCache<K,- V> 
- Returns:
- statistics about the cache
 
- 
getSizeReturns the current cache size.- Specified by:
- getSizein interface- IMemoryCache<K,- V> 
- Returns:
- The size value
 
- 
getCacheNameReturns the cache (aka "region") name.- Returns:
- The cacheName value
 
- 
waterfalPuts an item to the cache.- Specified by:
- waterfalin interface- IMemoryCache<K,- V> 
- Parameters:
- ce- the item
 
- 
dumpMapDump the cache map for debugging.
- 
getCacheAttributesReturns the CacheAttributes.- Specified by:
- getCacheAttributesin interface- IMemoryCache<K,- V> 
- Returns:
- The CacheAttributes value
 
- 
setCacheAttributesSets the CacheAttributes.- Specified by:
- setCacheAttributesin interface- IMemoryCache<K,- V> 
- Parameters:
- cattr- The new CacheAttributes value
 
- 
getCompositeCacheGets the cache hub / region that the MemoryCache is used by- Specified by:
- getCompositeCachein interface- IMemoryCache<K,- V> 
- Returns:
- The cache value
 
- 
removeByGroupRemove all keys of the same group hierarchy.- Parameters:
- key- the key
- Returns:
- true if something has been removed
 
- 
removeByHierarchyRemove all keys of the same name hierarchy.- Parameters:
- key- the key
- Returns:
- true if something has been removed
 
- 
lockedRemoveElementRemove element from control structure (guarded by the lock)- Parameters:
- me- the memory element descriptor
 
- 
removeRemoves an item from the cache. This method handles hierarchical removal. If the key is a String and ends with the CacheConstants.NAME_COMPONENT_DELIMITER, then all items with keys starting with the argument String will be removed.- Specified by:
- removein interface- IMemoryCache<K,- V> 
- Parameters:
- key-
- Returns:
- true if the removal was successful
- Throws:
- IOException
 
- 
getKeySetGet an Array of the keys for all elements in the memory cache- Specified by:
- getKeySetin interface- IMemoryCache<K,- V> 
- Returns:
- An Object[]
 
- 
getGet an item from the cache.- Specified by:
- getin interface- IMemoryCache<K,- V> 
- Parameters:
- key- Identifies item to find
- Returns:
- ICacheElement<K, V> if found, else null
- Throws:
- IOException
 
- 
lockedGetElementUpdate control structures after get (guarded by the lock)- Parameters:
- me- the memory element descriptor
 
 
-