Package net.sourceforge.jtds.jdbc.cache
Class SimpleLRUCache<K,V>
- java.lang.Object
-
- net.sourceforge.jtds.jdbc.cache.SimpleLRUCache<K,V>
-
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.- Author:
- Holger Rehn
-
-
Constructor Summary
Constructors Constructor Description SimpleLRUCache(int limit)
Constructs a new LRU cache with a limited capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description V
get(K key)
Get the value associated with the given key, if any.V
put(K key, V value)
Updates the LRU cache by adding a new entry.
-
-
-
Method Detail
-
put
public V put(K key, V value)
Updates the LRU cache by adding a new entry.
- Parameters:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key- Returns:
- previous value associated with key or
null
if there was no mapping for key; anull
value can also indicate that the cache previously associatednull
with the specified key - See Also:
Map.put(Object,Object)
-
-