Package net.sourceforge.jtds.jdbc.cache
Class SimpleLRUCache<K,V>
java.lang.Object
net.sourceforge.jtds.jdbc.cache.SimpleLRUCache<K,V>
Simple LRU cache for any type of object, based on a LinkedHashMap
with a maximum size.
- Author:
- Holger Rehn
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSimpleLRUCache(int limit) Constructs a new LRU cache with a limited capacity. -
Method Summary
-
Field Details
-
_Map
map backing the LRU cache
-
-
Constructor Details
-
SimpleLRUCache
public SimpleLRUCache(int limit) Constructs a new LRU cache with a limited capacity.
- Parameters:
limit- maximum number of entries in this cache
-
-
Method Details
-
put
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
nullif there was no mapping for key; anullvalue can also indicate that the cache previously associatednullwith the specified key - See Also:
-
get
Get the value associated with the given key, if any.
- Parameters:
key- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped, or
nullif this map contains no mapping for the key - See Also:
-