public class LruCache<K,V> extends java.util.LinkedHashMap<K,V> implements Cache<K,V>
| Constructor and Description |
|---|
LruCache(int maxSize)
Create a new cache and specify the maximum size of for the cache in
bytes, and the maximum lifetime of objects.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
V |
get(java.lang.Object key) |
long |
getCacheHits() |
long |
getCacheMisses() |
int |
getMaxCacheSize() |
boolean |
isEmpty() |
java.util.Set<K> |
keySet() |
V |
put(K key,
V value) |
void |
putAll(java.util.Map<? extends K,? extends V> m) |
V |
remove(java.lang.Object key) |
protected boolean |
removeEldestEntry(java.util.Map.Entry<K,V> eldest) |
void |
setMaxCacheSize(int maxCacheSize) |
int |
size() |
java.util.Collection<V> |
values() |
public LruCache(int maxSize)
maxSize - the maximum number of objects the cache will hold. -1
means the cache has no max size.public final V get(java.lang.Object key)
public final V remove(java.lang.Object key)
public final void clear()
public final int size()
public final boolean isEmpty()
public final java.util.Collection<V> values()
public final boolean containsKey(java.lang.Object key)
public final boolean containsValue(java.lang.Object value)
public final java.util.Set<K> keySet()
public final long getCacheHits()
public final long getCacheMisses()
public final int getMaxCacheSize()
getMaxCacheSize in interface Cache<K,V>public final void setMaxCacheSize(int maxCacheSize)
setMaxCacheSize in interface Cache<K,V>