|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jcs.engine.memory.AbstractMemoryCache<K,V>
org.apache.jcs.engine.memory.AbstractDoubleLinkedListMemoryCache<K,V>
public abstract class AbstractDoubleLinkedListMemoryCache<K extends Serializable,V extends Serializable>
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 | |
|---|---|
static class |
AbstractDoubleLinkedListMemoryCache.IteratorWrapper<K extends Serializable,V extends Serializable>
iteration aid |
static class |
AbstractDoubleLinkedListMemoryCache.MapEntryWrapper<K extends Serializable,V extends Serializable>
|
| Field Summary | |
|---|---|
protected int |
hitCnt
number of hits |
protected DoubleLinkedList<MemoryElementDescriptor<K,V>> |
list
thread-safe double linked list for lru |
protected int |
missCnt
number of misses |
| Fields inherited from class org.apache.jcs.engine.memory.AbstractMemoryCache |
|---|
cache, cacheAttributes, cacheName, chunkSize, elementAttributes, map, status |
| Constructor Summary | |
|---|---|
AbstractDoubleLinkedListMemoryCache()
|
|
| Method Summary | |
|---|---|
protected 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 void |
adjustListForGet(MemoryElementDescriptor<K,V> me)
Adjust the list as needed for a get. |
protected abstract MemoryElementDescriptor<K,V> |
adjustListForUpdate(ICacheElement<K,V> ce)
Children implement this to control the cache expiration algorithm |
Map<K,MemoryElementDescriptor<K,V>> |
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. |
int |
freeElements(int numberToFree)
This instructs the memory cache to remove the numberToFree according to its eviction policy. |
ICacheElement<K,V> |
get(K key)
Get an item from the cache If the item is found, it is removed from the list and added first. |
Iterator<Map.Entry<K,MemoryElementDescriptor<K,V>>> |
getIterator()
Gets the iterator attribute of the LRUMemoryCache object |
Set<K> |
getKeySet()
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<K,V> hub)
For post reflection creation initialization. |
boolean |
remove(K 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<K,V> |
spoolLastElement()
This spools the last element in the LRU, if one exists. |
void |
update(ICacheElement<K,V> 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, dumpMap, getCacheAttributes, getCacheName, getCompositeCache, getGroupKeys, getGroupNames, getMultiple, getQuiet, getSize, getStatus, setCacheAttributes, setScheduledExecutorService, waterfal |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected DoubleLinkedList<MemoryElementDescriptor<K extends Serializable,V extends Serializable>> list
protected int hitCnt
protected int missCnt
| Constructor Detail |
|---|
public AbstractDoubleLinkedListMemoryCache()
| Method Detail |
|---|
public void initialize(CompositeCache<K,V> hub)
initialize in interface IMemoryCache<K extends Serializable,V extends Serializable>initialize in class AbstractMemoryCache<K extends Serializable,V extends Serializable>hub - public Map<K,MemoryElementDescriptor<K,V>> createMap()
createMap in class AbstractMemoryCache<K extends Serializable,V extends Serializable>
public final void update(ICacheElement<K,V> ce)
throws IOException
If the max size is reached, an element will be put to disk.
update in interface IMemoryCache<K extends Serializable,V extends Serializable>update in class AbstractMemoryCache<K extends Serializable,V extends Serializable>ce - The cache element, or entry wrapper
IOException
protected abstract MemoryElementDescriptor<K,V> adjustListForUpdate(ICacheElement<K,V> ce)
throws IOException
ce -
IOException
public final ICacheElement<K,V> get(K key)
throws IOException
get in interface IMemoryCache<K extends Serializable,V extends Serializable>get in class AbstractMemoryCache<K extends Serializable,V extends Serializable>key - Identifies item to find
IOExceptionprotected abstract void adjustListForGet(MemoryElementDescriptor<K,V> me)
me -
public int freeElements(int numberToFree)
throws IOException
numberToFree -
IOException
protected ICacheElement<K,V> spoolLastElement()
throws Error
Error
public boolean remove(K key)
throws IOException
remove in interface IMemoryCache<K extends Serializable,V extends Serializable>remove in class AbstractMemoryCache<K extends Serializable,V extends Serializable>key -
IOException
public void removeAll()
throws IOException
removeAll in interface IMemoryCache<K extends Serializable,V extends Serializable>removeAll in class AbstractMemoryCache<K extends Serializable,V extends Serializable>IOExceptionprotected MemoryElementDescriptor<K,V> addFirst(ICacheElement<K,V> ce)
ce - The feature to be added to the First
protected MemoryElementDescriptor<K,V> addLast(ICacheElement<K,V> ce)
ce - The feature to be added to the First
public void dumpCacheEntries()
protected int dumpCacheSize()
protected void verifyCache()
public Iterator<Map.Entry<K,MemoryElementDescriptor<K,V>>> getIterator()
getIterator in interface IMemoryCache<K extends Serializable,V extends Serializable>getIterator in class AbstractMemoryCache<K extends Serializable,V extends Serializable>public Set<K> getKeySet()
getKeySet in interface IMemoryCache<K extends Serializable,V extends Serializable>getKeySet in class AbstractMemoryCache<K extends Serializable,V extends Serializable>public IStats getStatistics()
getStatistics in interface IMemoryCache<K extends Serializable,V extends Serializable>getStatistics in class AbstractMemoryCache<K extends Serializable,V extends Serializable>org.apache.jcs.engine.memory.IMemoryCache#getStatistics()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||