Class LRUCache<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
org.apache.activemq.artemis.selector.impl.LRUCache<K,V>
- All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLRUCache()Default constructor for an LRU Cache The default capacity is 10000LRUCache(int maximumCacheSize) Constructs a LRUCache with a maximum capacityLRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder) Constructs an emptyLRUCacheinstance with the specified initial capacity, maximumCacheSize,load factor and ordering mode. -
Method Summary
Modifier and TypeMethodDescriptionintprotected voidonCacheEviction(Map.Entry<K, V> eldest) protected booleanremoveEldestEntry(Map.Entry<K, V> eldest) voidsetMaxCacheSize(int maxCacheSize) Methods inherited from class LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, valuesMethods inherited from class HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class AbstractMap
equals, hashCode, toStringMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Field Details
-
maxCacheSize
protected int maxCacheSize
-
-
Constructor Details
-
LRUCache
public LRUCache()Default constructor for an LRU Cache The default capacity is 10000 -
LRUCache
public LRUCache(int maximumCacheSize) Constructs a LRUCache with a maximum capacity -
LRUCache
public LRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder) Constructs an emptyLRUCacheinstance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.- Parameters:
initialCapacity- the initial capacity.loadFactor- the load factor.accessOrder- the ordering mode -truefor access-order,falsefor insertion-order.- Throws:
IllegalArgumentException- if the initial capacity is negative or the load factor is non-positive.
-
-
Method Details
-
getMaxCacheSize
public int getMaxCacheSize() -
setMaxCacheSize
public void setMaxCacheSize(int maxCacheSize) -
removeEldestEntry
- Overrides:
removeEldestEntryin classLinkedHashMap<K,V>
-
onCacheEviction
-