Package games.stendhal.client
Class MemoryCache<K,V>
java.lang.Object
games.stendhal.client.MemoryCache<K,V>
- Type Parameters:
K
- key typeV
- value type
A Map like cache that uses SoftReferences to store the cached items to allow
the garbage collector to reclaim the memory in need. Unlike WeakHashMap, the
entries are retained by value rather than by key.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
MemoryCache
public MemoryCache()
-
-
Method Details
-
get
Get an object from the cache.- Parameters:
key
- the key corresponding to the object- Returns:
- cached object, or
null
if there's no object for the key in the cache
-
put
Store an object to the cache.- Parameters:
key
- key for accessing the objectvalue
- the object to be stored
-