Class AbstractDoubleLinkedListMemoryCache<K,V> 
java.lang.Object
org.apache.commons.jcs3.engine.memory.AbstractMemoryCache<K,V>
 
org.apache.commons.jcs3.engine.memory.AbstractDoubleLinkedListMemoryCache<K,V> 
- All Implemented Interfaces:
- IMemoryCache<K,- V> 
- Direct Known Subclasses:
- FIFOMemoryCache,- LRUMemoryCache,- MRUMemoryCache
This class contains methods that are common to memory caches using the double linked list, such
 as the LRU, MRU, FIFO, and LIFO caches.
 
Children can control the expiration algorithm by controlling the update and get. The last item in the list will be the one removed when the list fills. For instance LRU should more items to the front as they are used. FIFO should simply add new items to the front of the list.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected DoubleLinkedList<MemoryElementDescriptor<K,V>> thread-safe double linked list for lru
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected MemoryElementDescriptor<K,V> addFirst(ICacheElement<K, V> ce) Adds a new node to the start of the link list.protected MemoryElementDescriptor<K,V> addLast(ICacheElement<K, V> ce) Adds a new node to the end of the link list.protected abstract voidAdjust the list as needed for a get.protected abstract MemoryElementDescriptor<K,V> Children implement this to control the cache expiration algorithmThis is called by super initialize.intfreeElements(int numberToFree) This instructs the memory cache to remove the numberToFree according to its eviction policy.Get an item from the cache.This returns semi-structured information on the memory cache, such as the size, put count, hit count, and miss count.voidinitialize(CompositeCache<K, V> hub) For post reflection creation initialization.protected voidUpdate control structures after get (guarded by the lock)protected voidRemoves all cached items from the cache control structures.protected voidRemove element from control structure (guarded by the lock)final voidupdate(ICacheElement<K, V> ce) Calls the abstract method updateList.Methods inherited from class org.apache.commons.jcs3.engine.memory.AbstractMemoryCachedispose, dumpMap, getCacheAttributes, getCacheName, getCompositeCache, getKeySet, getMultiple, getQuiet, getSize, remove, removeAll, removeByGroup, removeByHierarchy, setCacheAttributes, waterfal
- 
Field Details- 
listthread-safe double linked list for lru
 
- 
- 
Constructor Details- 
AbstractDoubleLinkedListMemoryCachepublic AbstractDoubleLinkedListMemoryCache()
 
- 
- 
Method Details- 
initializeFor post reflection creation initialization.- Specified by:
- initializein interface- IMemoryCache<K,- V> 
- Overrides:
- initializein class- AbstractMemoryCache<K,- V> 
- Parameters:
- hub-
 
- 
createMapThis is called by super initialize. NOTE: should return a thread safe map- Specified by:
- createMapin class- AbstractMemoryCache<K,- V> 
- Returns:
- new ConcurrentHashMap()
 
- 
updateCalls the abstract method updateList.If the max size is reached, an element will be put to disk. - Specified by:
- updatein interface- IMemoryCache<K,- V> 
- Specified by:
- updatein class- AbstractMemoryCache<K,- V> 
- Parameters:
- ce- The cache element, or entry wrapper
- Throws:
- IOException
 
- 
adjustListForUpdateprotected abstract MemoryElementDescriptor<K,V> adjustListForUpdate(ICacheElement<K, V> ce) throws IOExceptionChildren implement this to control the cache expiration algorithm- Parameters:
- ce-
- Returns:
- MemoryElementDescriptor the new node
- Throws:
- IOException
 
- 
freeElementsThis instructs the memory cache to remove the numberToFree according to its eviction policy. For example, the LRUMemoryCache will remove the numberToFree least recently used items. These will be spooled to disk if a disk auxiliary is available.- Parameters:
- numberToFree-
- Returns:
- the number that were removed. if you ask to free 5, but there are only 3, you will get 3.
 
- 
getDescription copied from class:AbstractMemoryCacheGet an item from the cache.- Specified by:
- getin interface- IMemoryCache<K,- V> 
- Overrides:
- getin class- AbstractMemoryCache<K,- V> 
- Parameters:
- key- Identifies item to find
- Returns:
- ICacheElement<K, V> if found, else null
- Throws:
- IOException- Description of the Exception
- See Also:
 
- 
adjustListForGetAdjust the list as needed for a get. This allows children to control the algorithm- Parameters:
- me-
 
- 
lockedGetElementUpdate control structures after get (guarded by the lock)- Specified by:
- lockedGetElementin class- AbstractMemoryCache<K,- V> 
- Parameters:
- me- the memory element descriptor
 
- 
lockedRemoveElementRemove element from control structure (guarded by the lock)- Specified by:
- lockedRemoveElementin class- AbstractMemoryCache<K,- V> 
- Parameters:
- me- the memory element descriptor
 
- 
lockedRemoveAllRemoves all cached items from the cache control structures. (guarded by the lock)- Specified by:
- lockedRemoveAllin class- AbstractMemoryCache<K,- V> 
 
- 
addFirstAdds a new node to the start of the link list.- Parameters:
- ce- The feature to be added to the First
- Returns:
- MemoryElementDescriptor
 
- 
addLastAdds a new node to the end of the link list.- Parameters:
- ce- The feature to be added to the First
- Returns:
- MemoryElementDescriptor
 
- 
getStatisticsThis returns semi-structured information on the memory cache, such as the size, put count, hit count, and miss count.- Specified by:
- getStatisticsin interface- IMemoryCache<K,- V> 
- Overrides:
- getStatisticsin class- AbstractMemoryCache<K,- V> 
- Returns:
- statistics about the cache
- See Also:
 
 
-