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, 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 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>
Copyright © 2016 JBoss by Red Hat. All rights reserved.