K
- The type of a key with which a value is associated in the cache.V
- The type of a value which is stored in the cache.public class SoftCache<K,V> extends Object
A simple cache using SoftReference
s to store values. It allows
the values to be garbage collected if no more needed. When putting values
into the cache the values are associated with keys. The keys are then used
to retrieve values from the cache.
Note: This class is not thread-safe!
Constructor and Description |
---|
SoftCache() |
Modifier and Type | Method and Description |
---|---|
V |
get(K key)
Returns the value to which the specified key is mapped,
or
null if this cache contains no mapping for the key or
if the value to which the specified key is mapped has been garbage
collected. |
void |
put(K key,
V value)
Associates the specified value with the specified key in this cache.
|
public V get(K key)
null
if this cache contains no mapping for the key or
if the value to which the specified key is mapped has been garbage
collected.key
- the key whose associated value is to be returnednull
if no value is available for
the keypublic void put(K key, V value)
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyCopyright © 2007-2020 Whitestein Technologies. All Rights Reserved.