public class WSLruCache extends Object
Null keys are not allowed. WSLruCache is synchronized.
Modifier and Type | Field and Description |
---|---|
protected int |
m_cacheCapacity |
protected Map<Object,com.webmethods.caf.wsclient.cache.impl.WSLruCache.CacheItem> |
m_cacheMap |
protected long |
m_entryTimeout |
Constructor and Description |
---|
WSLruCache(int maxCapacity,
long maxFreshTimeout)
Create the LRU cache with a specific capacity and freshness timeout.
|
Modifier and Type | Method and Description |
---|---|
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<Object> |
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<com.webmethods.caf.wsclient.cache.impl.WSLruCache.CacheItem> |
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<Object> |
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<com.webmethods.caf.wsclient.cache.impl.WSLruCache.CacheItem> |
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
|
protected Map<Object,com.webmethods.caf.wsclient.cache.impl.WSLruCache.CacheItem> m_cacheMap
protected int m_cacheCapacity
protected long m_entryTimeout
public WSLruCache(int maxCapacity, long maxFreshTimeout)
maxCapacity
- - minimum capacity of the cachemaxCapacity
- - maximum cache entry age (in milliseconds)public void clear()
public int size()
public int getMaxCapacity()
public boolean containsKey(Object key)
key
- the unique key to the item in the cachepublic Object get(Object key)
key
- key to lookup the itemprotected Object getFresh(Object key)
key
- - the cache key objectpublic Object put(Object key, Object value)
key
- key to store datavalue
- value to be storedpublic Object remove(Object key)
key
- the key to removepublic Iterator<Object> getKeys()
public Iterator<Object> getFreshKeys()
public Iterator<com.webmethods.caf.wsclient.cache.impl.WSLruCache.CacheItem> getValues()
public Iterator<com.webmethods.caf.wsclient.cache.impl.WSLruCache.CacheItem> getFreshValues()
protected void printCacheToConsole()