public abstract class AbstractDoulbeLinkedListMemoryCache extends AbstractMemoryCache
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.
| Modifier and Type | Class and Description |
|---|---|
class |
AbstractDoulbeLinkedListMemoryCache.IteratorWrapper
iteration aid
|
class |
AbstractDoulbeLinkedListMemoryCache.MapEntryWrapper |
| Modifier and Type | Field and Description |
|---|---|
protected int |
hitCnt
number of hits
|
protected DoubleLinkedList |
list
thread-safe double linked list for lru
|
protected int |
missCnt
number of misses
|
| Constructor and Description |
|---|
AbstractDoulbeLinkedListMemoryCache() |
| Modifier and Type | Method and Description |
|---|---|
protected MemoryElementDescriptor |
addFirst(ICacheElement ce)
Adds a new node to the start of the link list.
|
protected MemoryElementDescriptor |
addLast(ICacheElement ce)
Adds a new node to the end of the link list.
|
protected abstract void |
adjustListForGet(MemoryElementDescriptor me)
Adjust the list as needed for a get.
|
protected abstract MemoryElementDescriptor |
adjustListForUpdate(ICacheElement ce)
Children implement this to control the cache expiration algorithm
|
java.util.Map |
createMap()
This is called by super initialize.
|
void |
dumpCacheEntries()
Dump the cache entries from first to list for debugging.
|
protected int |
dumpCacheSize()
Returns the size of the list.
|
void |
dumpMap()
Dump the cache map for debugging.
|
int |
freeElements(int numberToFree)
This instructs the memory cache to remove the numberToFree according to its eviction
policy.
|
ICacheElement |
get(java.io.Serializable key)
Get an item from the cache If the item is found, it is removed from the list and added first.
|
java.util.Iterator |
getIterator()
Gets the iterator attribute of the LRUMemoryCache object
|
java.lang.Object[] |
getKeyArray()
Get an Array of the keys for all elements in the memory cache
|
IStats |
getStatistics()
This returns semi-structured information on the memory cache, such as the size, put count,
hit count, and miss count.
|
void |
initialize(CompositeCache hub)
For post reflection creation initialization.
|
boolean |
remove(java.io.Serializable key)
Removes an item from the cache.
|
void |
removeAll()
Remove all of the elements from both the Map and the linked list implementation.
|
protected ICacheElement |
spoolLastElement()
This spools the last element in the LRU, if one exists.
|
void |
update(ICacheElement ce)
Calls the abstract method updateList.
|
protected void |
verifyCache()
Checks to see if all the items that should be in the cache are.
|
dispose, getCacheAttributes, getCacheName, getCompositeCache, getGroupKeys, getMultiple, getQuiet, getSize, getStatus, setCacheAttributes, waterfalprotected DoubleLinkedList list
protected int hitCnt
protected int missCnt
public void initialize(CompositeCache hub)
initialize in interface IMemoryCacheinitialize in class AbstractMemoryCachehub - public java.util.Map createMap()
createMap in class AbstractMemoryCachepublic final void update(ICacheElement ce) throws java.io.IOException
If the max size is reached, an element will be put to disk.
update in interface IMemoryCacheupdate in class AbstractMemoryCachece - The cache element, or entry wrapperjava.io.IOExceptionprotected abstract MemoryElementDescriptor adjustListForUpdate(ICacheElement ce) throws java.io.IOException
ce - java.io.IOExceptionpublic final ICacheElement get(java.io.Serializable key) throws java.io.IOException
get in interface IMemoryCacheget in class AbstractMemoryCachekey - Identifies item to findjava.io.IOExceptionprotected abstract void adjustListForGet(MemoryElementDescriptor me)
me - public int freeElements(int numberToFree)
throws java.io.IOException
numberToFree - java.io.IOExceptionprotected ICacheElement spoolLastElement() throws java.lang.Error
java.lang.Errorpublic boolean remove(java.io.Serializable key)
throws java.io.IOException
remove in interface IMemoryCacheremove in class AbstractMemoryCachekey - java.io.IOExceptionpublic void removeAll()
throws java.io.IOException
removeAll in interface IMemoryCacheremoveAll in class AbstractMemoryCachejava.io.IOExceptionprotected MemoryElementDescriptor addFirst(ICacheElement ce)
ce - The feature to be added to the Firstprotected MemoryElementDescriptor addLast(ICacheElement ce)
ce - The feature to be added to the Firstpublic void dumpMap()
public void dumpCacheEntries()
protected int dumpCacheSize()
protected void verifyCache()
public java.util.Iterator getIterator()
getIterator in interface IMemoryCachegetIterator in class AbstractMemoryCachepublic java.lang.Object[] getKeyArray()
getKeyArray in interface IMemoryCachegetKeyArray in class AbstractMemoryCachepublic IStats getStatistics()
getStatistics in interface IMemoryCachegetStatistics in class AbstractMemoryCacheIMemoryCache.getStatistics()Copyright © 2002-2013 Apache Software Foundation. All Rights Reserved.