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, waterfal
protected DoubleLinkedList list
protected int hitCnt
protected int missCnt
public void initialize(CompositeCache hub)
initialize
in interface IMemoryCache
initialize
in class AbstractMemoryCache
hub
- public java.util.Map createMap()
createMap
in class AbstractMemoryCache
public 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 IMemoryCache
update
in class AbstractMemoryCache
ce
- The cache element, or entry wrapperjava.io.IOException
protected abstract MemoryElementDescriptor adjustListForUpdate(ICacheElement ce) throws java.io.IOException
ce
- java.io.IOException
public final ICacheElement get(java.io.Serializable key) throws java.io.IOException
get
in interface IMemoryCache
get
in class AbstractMemoryCache
key
- Identifies item to findjava.io.IOException
protected abstract void adjustListForGet(MemoryElementDescriptor me)
me
- public int freeElements(int numberToFree) throws java.io.IOException
numberToFree
- java.io.IOException
protected ICacheElement spoolLastElement() throws java.lang.Error
java.lang.Error
public boolean remove(java.io.Serializable key) throws java.io.IOException
remove
in interface IMemoryCache
remove
in class AbstractMemoryCache
key
- java.io.IOException
public void removeAll() throws java.io.IOException
removeAll
in interface IMemoryCache
removeAll
in class AbstractMemoryCache
java.io.IOException
protected 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 IMemoryCache
getIterator
in class AbstractMemoryCache
public java.lang.Object[] getKeyArray()
getKeyArray
in interface IMemoryCache
getKeyArray
in class AbstractMemoryCache
public IStats getStatistics()
getStatistics
in interface IMemoryCache
getStatistics
in class AbstractMemoryCache
IMemoryCache.getStatistics()
Copyright © 2002-2013 Apache Software Foundation. All Rights Reserved.