public class SimpleLRUCache<K,V>
extends java.lang.Object
Simple LRU cache for any type of object, based on a LinkedHashMap
with a maximum size.
Modifier and Type | Field and Description |
---|---|
private java.util.Map<K,V> |
_Map
map backing the LRU cache
|
Constructor and Description |
---|
SimpleLRUCache(int limit)
Constructs a new LRU cache with a limited capacity.
|
public SimpleLRUCache(int limit)
Constructs a new LRU cache with a limited capacity.
limit
- maximum number of entries in this cachepublic V put(K key, V value)
Updates the LRU cache by adding a new entry.
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keynull
if there was no
mapping for key; a null
value can also indicate that the cache
previously associated null
with the specified keyMap.put(Object,Object)
Generated on June 8 2013