public class LRUCache<K,V> extends AbstractMap<K,V> implements ConcurrentMap<K,V>
To reduce contention, entry allocation and eviction execute in a sampling fashion (entry hits modulo N). Eviction follows an LRU approach (oldest sampled entries are removed first) when the cache is out of capacity.
| Modifier and Type | Class and Description |
|---|---|
static class |
LRUCache.CacheEntry<K,V> |
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
LRUCache(int maxEntries) |
LRUCache(int maxEntries,
RemoveCallback<K,V> removeCallback) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object key) |
V |
put(K key,
V newValue) |
V |
put(K key,
V newValue,
boolean ifAbsent) |
V |
putIfAbsent(K key,
V value) |
V |
remove(Object key) |
boolean |
remove(Object key,
Object value) |
V |
replace(K key,
V newValue) |
boolean |
replace(K key,
V oldValue,
V newValue) |
int |
size() |
clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAllcontainsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, valuespublic LRUCache(int maxEntries)
public LRUCache(int maxEntries,
RemoveCallback<K,V> removeCallback)
public void clear()
public int size()
public V putIfAbsent(K key, V value)
putIfAbsent in interface ConcurrentMap<K,V>putIfAbsent in interface Map<K,V>Copyright © 2019 JBoss by Red Hat. All rights reserved.