public class LruCache<K,V> extends LinkedHashMap<K,V> implements Cache<K,V>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<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(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object key) |
long |
getCacheHits() |
long |
getCacheMisses() |
int |
getMaxCacheSize() |
boolean |
isEmpty() |
Set<K> |
keySet() |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> m) |
V |
remove(Object key) |
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest) |
void |
setMaxCacheSize(int maxCacheSize) |
int |
size() |
Collection<V> |
values() |
forEach, getOrDefault, replaceAllclone, compute, computeIfAbsent, computeIfPresent, merge, putIfAbsent, remove, replace, replaceequals, hashCode, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, hashCode, merge, putIfAbsent, remove, replace, replacepublic LruCache(int maxSize)
maxSize - the maximum number of objects the cache will hold. -1
means the cache has no max size.protected final boolean removeEldestEntry(Map.Entry<K,V> eldest)
removeEldestEntry in class LinkedHashMap<K,V>public final void clear()
public final int size()
public final boolean isEmpty()
public final Collection<V> values()
public final boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in class HashMap<K,V>public final boolean containsValue(Object value)
containsValue in interface Map<K,V>containsValue in class LinkedHashMap<K,V>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>Copyright © 2015 Ignite Realtime. All rights reserved.