Package rocks.xmpp.util.cache
Class LruCache<K,V>
- java.lang.Object
-
- rocks.xmpp.util.cache.LruCache<K,V>
-
- Type Parameters:
K- The key.V- The value.
- All Implemented Interfaces:
Map<K,V>
public final class LruCache<K,V> extends Object implements Map<K,V>
A simple concurrent implementation of a least-recently-used cache.This cache is keeps a maximal number of items in memory and removes the least-recently-used item, when new items are added.
-
-
Constructor Summary
Constructors Constructor Description LruCache(int maxEntries)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Vcompute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)VcomputeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)VcomputeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()Vget(Object key)booleanisEmpty()Set<K>keySet()Vmerge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)Vput(K key, V value)voidputAll(Map<? extends K,? extends V> m)VputIfAbsent(K key, V value)Vremove(Object key)booleanremove(Object key, Object value)Vreplace(K key, V value)booleanreplace(K key, V oldValue, V newValue)intsize()Collection<V>values()-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
equals, forEach, getOrDefault, hashCode, replaceAll
-
-
-
-
Method Detail
-
containsKey
public final boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public final boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
putIfAbsent
public final V putIfAbsent(K key, V value)
- Specified by:
putIfAbsentin interfaceMap<K,V>
-
computeIfAbsent
public final V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
- Specified by:
computeIfAbsentin interfaceMap<K,V>
-
computeIfPresent
public final V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
- Specified by:
computeIfPresentin interfaceMap<K,V>
-
compute
public final V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
-
-