|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jcs.engine.memory.AbstractMemoryCache
org.apache.jcs.engine.memory.AbstractDoulbeLinkedListMemoryCache
public abstract class AbstractDoulbeLinkedListMemoryCache
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.
Nested Class Summary | |
---|---|
class |
AbstractDoulbeLinkedListMemoryCache.IteratorWrapper
iteration aid |
class |
AbstractDoulbeLinkedListMemoryCache.MapEntryWrapper
|
Field Summary | |
---|---|
protected int |
hitCnt
number of hits |
protected DoubleLinkedList |
list
thread-safe double linked list for lru |
protected int |
missCnt
number of misses |
Fields inherited from class org.apache.jcs.engine.memory.AbstractMemoryCache |
---|
attr, cache, cacheName, cattr, chunkSize, map, status |
Constructor Summary | |
---|---|
AbstractDoulbeLinkedListMemoryCache()
|
Method Summary | |
---|---|
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. |
Methods inherited from class org.apache.jcs.engine.memory.AbstractMemoryCache |
---|
dispose, getCacheAttributes, getCacheName, getCompositeCache, getGroupKeys, getMultiple, getQuiet, getSize, getStatus, setCacheAttributes, waterfal |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DoubleLinkedList list
protected int hitCnt
protected int missCnt
Constructor Detail |
---|
public AbstractDoulbeLinkedListMemoryCache()
Method Detail |
---|
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 wrapper
java.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 find
java.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 First
protected MemoryElementDescriptor addLast(ICacheElement ce)
ce
- The feature to be added to the First
public 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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |