K - V - public class LRUCache<K,V> extends LinkedHashMap<K,V>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Modifier and Type | Field and Description |
|---|---|
protected int |
maxCacheSize |
| Constructor and Description |
|---|
LRUCache()
Default constructor for an LRU Cache The default capacity is 10000
|
LRUCache(int maximumCacheSize)
Constructs a LRUCache with a maximum capacity
|
LRUCache(int initialCapacity,
int maximumCacheSize,
float loadFactor,
boolean accessOrder)
Constructs an empty LRUCache instance with the specified
initial capacity, maximumCacheSize,load factor and ordering mode.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getMaxCacheSize() |
protected void |
onCacheEviction(Map.Entry<K,V> eldest) |
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest) |
void |
setMaxCacheSize(int maxCacheSize) |
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, sizeprotected int maxCacheSize
public LRUCache()
public LRUCache(int maximumCacheSize)
maximumCacheSize - public LRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder)
initialCapacity - the initial capacity.maximumCacheSize - loadFactor - the load factor.accessOrder - the ordering mode - true for access-order,
false for insertion-order.IllegalArgumentException - if the initial capacity is negative or
the load factor is non-positive.public int getMaxCacheSize()
public void setMaxCacheSize(int maxCacheSize)
maxCacheSize - The maxCacheSize to set.protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
removeEldestEntry in class LinkedHashMap<K,V>protected void onCacheEviction(Map.Entry<K,V> eldest)
Copyright © 2005–2016 FuseSource, Corp.. All rights reserved.