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, get
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values
equals, hashCode, toString
protected 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.