|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.webmethods.caf.wsclient.cache.impl.WSLruCache
public class WSLruCache
Fixed length cache with a LRU replacement policy. If cache items implement CacheListener, they will be informed when they're removed from the cache.
Null keys are not allowed. WSLruCache is synchronized.
Field Summary | |
---|---|
protected int |
m_cacheCapacity
|
protected Map |
m_cacheMap
|
protected long |
m_entryTimeout
|
Constructor Summary | |
---|---|
WSLruCache(int maxCapacity,
long maxFreshTimeout)
Create the LRU cache with a specific capacity and freshness timeout. |
Method Summary | |
---|---|
void |
clear()
Clears all entries from the cache |
boolean |
containsKey(Object key)
Determines if an item is in the Cache |
Object |
get(Object key)
Get an item from the cache and make it most recently used. |
protected Object |
getFresh(Object key)
Get an item from the hash and return it. |
Iterator |
getFreshKeys()
Returns the fresh keys stored in the cache Note: this is a snapshot of the keys and is therefore safe to iterate, however care needs to be taken when using these keys for cache lookups as the key may no longer exist. |
Iterator |
getFreshValues()
Returns the values stored in the cache Note: this is a snapshot of the values and is therefore safe to iterate but may not reflect the current state of the cache. |
Iterator |
getKeys()
Get an iterator for the keys of the cache, including both fresh and stale entries Note: this is a snapshot of the keys and is therefore safe to iterate, however care needs to be taken when using these keys for cache lookups as the key may no longer exist. |
int |
getMaxCapacity()
The current capacity of this cache |
Iterator |
getValues()
Get an iterator for the values of the cache that includes both stale and fresh enties Note: this is a snapshot of the values and is therefore safe to iterate but may not reflect the current state of the cache. |
protected void |
printCacheToConsole()
|
Object |
put(Object key,
Object value)
Puts a new item in the cache and returns the previous value stored under that key |
Object |
remove(Object key)
Removes an item from the cache |
int |
size()
The current size of the cache |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map m_cacheMap
protected int m_cacheCapacity
protected long m_entryTimeout
Constructor Detail |
---|
public WSLruCache(int maxCapacity, long maxFreshTimeout)
maxCapacity
- - minimum capacity of the cachemaxCapacity
- - maximum cache entry age (in milliseconds)Method Detail |
---|
public void clear()
public int size()
public int getMaxCapacity()
public boolean containsKey(Object key)
key
- the unique key to the item in the cache
public Object get(Object key)
key
- key to lookup the item
protected Object getFresh(Object key)
key
- - the cache key object
public Object put(Object key, Object value)
key
- key to store datavalue
- value to be stored
public Object remove(Object key)
key
- the key to remove
public Iterator getKeys()
public Iterator getFreshKeys()
public Iterator getValues()
public Iterator getFreshValues()
protected void printCacheToConsole()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |