Class LeastRecentlyUsed<T,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<T,V>
-
- org.forgerock.openam.utils.collections.LeastRecentlyUsed<T,V>
-
- Type Parameters:
T- The cache key type.V- The cache value type.
- All Implemented Interfaces:
Serializable,Cloneable,Map<T,V>
public class LeastRecentlyUsed<T,V> extends LinkedHashMap<T,V>
A simple Least Recently Used cache implementation based on the standard Java SDK LinkedHashMap class.Specially maintains a cache up to the size limit specified. After which point will start to discard entries in Least Recently Used order.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description LeastRecentlyUsed(int maxSize)Constructs a new LeastRecentlyUsed cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetMaxSize()Get the maximum size of the cache.protected booleanremoveEldestEntry(Map.Entry<T,V> entry)-
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
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
-
-
-
Method Detail
-
removeEldestEntry
protected boolean removeEldestEntry(Map.Entry<T,V> entry)
- Overrides:
removeEldestEntryin classLinkedHashMap<T,V>
-
getMaxSize
public int getMaxSize()
Get the maximum size of the cache.- Returns:
- the maximum size of the cache.
-
-