|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.thimbleware.jmemcached.LRUCache<ID_TYPE,ITEM_TYPE>
public final class LRUCache<ID_TYPE,ITEM_TYPE>
Simple non-thread-safe LRU hash map cache. Thread safety is expected to be provided by the caller.
| Constructor Summary | |
|---|---|
LRUCache(int maximumItems,
long maximumSize,
long ceilingSize)
Caches are created as empty, and populated through use. |
|
| Method Summary | |
|---|---|
void |
clear()
Start from beginning, and remove all items from the cache; if cache is disabled, do nothing. |
long |
count()
|
ITEM_TYPE |
get(ID_TYPE aId)
Retrieve an existing item from the cache. |
long |
getCeilingSize()
|
int |
getMaximumItems()
|
long |
getMaximumSize()
|
long |
getSize()
|
boolean |
has(ID_TYPE aId)
Return true only if the corresponding item is in the cache, and has been in it for no more that fRefreshInterval milliseconds; if caching is disabled, then always return false. |
java.util.Set<ID_TYPE> |
keys()
|
void |
put(ID_TYPE aId,
ITEM_TYPE aItem,
long item_size)
If the item is already present, then replace it; otherwise, add it. |
void |
remove(ID_TYPE key)
Remove an entry from the cache |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LRUCache(int maximumItems,
long maximumSize,
long ceilingSize)
maximumItems - maximum number of items allowed in the cachemaximumSize - maximum size in bytes of the cacheceilingSize - number of bytes to attempt to leave as ceiling room| Method Detail |
|---|
public boolean has(ID_TYPE aId)
aId - is non-null.
java.lang.IllegalArgumentException - if a param does not comply.public ITEM_TYPE get(ID_TYPE aId)
aId - is non-null, and corresponds to an existing item in the cache.
java.lang.IllegalArgumentException - if aId is null, or if the item is not in the cache
java.lang.IllegalStateException - if the item in the cache is null or the cache is disabled
public void put(ID_TYPE aId,
ITEM_TYPE aItem,
long item_size)
aId - is non-nullaItem - is non-nullitem_size - is the size of aItem in bytes
java.lang.IllegalArgumentException - if param does not complypublic void remove(ID_TYPE key)
key - the key for the entrypublic void clear()
public java.util.Set<ID_TYPE> keys()
public long count()
public int getMaximumItems()
public long getSize()
public long getMaximumSize()
public long getCeilingSize()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||