public class SoftCache
extends java.util.HashMap
Map
that provides caching and retrieving of objects
via SoftReference
. Entries put in the cache are cleared when the
value objects become unreachable.Constructor and Description |
---|
SoftCache() |
SoftCache(int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
get(java.lang.Object key)
Looks for the key in the cache.
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the passed key with the value via
SoftReference . |
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
SoftReference
.put
in interface java.util.Map
put
in class java.util.HashMap
key
- a key with which the specified value is to be associated.value
- a value to be associated with the key.null
if there was no
value associated, or if it became unreachable. A null
value
can also be returned, if it was previously associated with the key.public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
get
in class java.util.HashMap
key
- a key for which the value should be returned.null
if the entry for the passed
key is missing, or if the value become unreachable, or if the
null
value was associated with the key.