public class LRUMap<K,V> extends LinkedHashMap<K,V>
LinkedHashMap.
This cache has a fixed maximum number of elements (cacheSize). If the cache is
full and another entry is added, the LRU (least recently used) entry is dropped.
Note: This class is not thread-safe.
| Modifier and Type | Class and Description |
|---|---|
static interface |
LRUMap.RemovalListener<K,V>
An object that can receive a notification when an entry is removed from a LRUMap.
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
LRUMap(int cacheSize) |
LRUMap(int cacheSize,
LRUMap.RemovalListener<K,V> removalListener) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest) |
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, valuesclone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeequals, hashCode, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizepublic LRUMap(int cacheSize)
public LRUMap(int cacheSize,
LRUMap.RemovalListener<K,V> removalListener)
protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
removeEldestEntry in class LinkedHashMap<K,V>Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.