Package org.apache.dubbo.common.utils
Class LRUCache<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
org.apache.dubbo.common.utils.LRUCache<K,V>
- Type Parameters:
K- keyV- value
- All Implemented Interfaces:
Serializable,Cloneable,Map<K,,V> SequencedMap<K,V>
A 'least recently used' cache based on LinkedHashMap.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()computeIfAbsent(K key, Function<? super K, ? extends V> fn) booleancontainsKey(Object key) intvoidlock()putIfAbsent(K key, V value) voidvoidsetMaxCapacity(int maxCapacity) intsize()Methods inherited from class java.util.LinkedHashMap
containsValue, entrySet, forEach, getOrDefault, keySet, newLinkedHashMap, putFirst, putLast, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, valuesMethods inherited from class java.util.HashMap
clone, compute, computeIfPresent, isEmpty, merge, newHashMap, putAll, remove, replace, replaceMethods inherited from class java.util.AbstractMap
equals, hashCode, toStringMethods inherited from interface java.util.Map
compute, computeIfPresent, equals, hashCode, isEmpty, merge, putAll, remove, replace, replaceMethods inherited from interface java.util.SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry
-
Constructor Details
-
LRUCache
public LRUCache() -
LRUCache
public LRUCache(int maxCapacity)
-
-
Method Details
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Overrides:
containsKeyin classHashMap<K,V>
-
get
-
put
-
remove
-
size
public int size() -
clear
public void clear() -
putIfAbsent
- Specified by:
putIfAbsentin interfaceMap<K,V> - Overrides:
putIfAbsentin classHashMap<K,V>
-
computeIfAbsent
- Specified by:
computeIfAbsentin interfaceMap<K,V> - Overrides:
computeIfAbsentin classHashMap<K,V>
-
lock
public void lock() -
releaseLock
public void releaseLock() -
getMaxCapacity
public int getMaxCapacity() -
setMaxCapacity
public void setMaxCapacity(int maxCapacity)
-