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, values
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
equals, hashCode, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
public 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–2022 The Apache Software Foundation. All rights reserved.