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>
-
- Type Parameters:
K-V-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map<K,V>
public class LRUCache<K,V> extends java.util.LinkedHashMap<K,V>A Simple LRU Cache- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intmaxCacheSize
-
Constructor Summary
Constructors Constructor Description LRUCache()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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetMaxCacheSize()protected voidonCacheEviction(java.util.Map.Entry<K,V> eldest)protected booleanremoveEldestEntry(java.util.Map.Entry<K,V> eldest)voidsetMaxCacheSize(int maxCacheSize)-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
-
-
-
Constructor Detail
-
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- Parameters:
maximumCacheSize-
-
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.maximumCacheSize-loadFactor- the load factor.accessOrder- the ordering mode -truefor access-order,falsefor insertion-order.- Throws:
java.lang.IllegalArgumentException- if the initial capacity is negative or the load factor is non-positive.
-
-