public class SoftSmartCache<K,V> extends Object implements SmartCache<K,V>
There is no contains(key) method because it makes no sense - after contains() returns true, the garbage collector may remove the value that was contained. Instead the code should call get() and keep a reference to the value to prevent garbage collection.
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
SoftSmartCache.CacheReference
an entry in the cache that contains the key for
the cache map to remove the entry when its value
has been garbage collected
|
| Constructor and Description |
|---|
SoftSmartCache() |
public V put(K key, V value)
SmartCacheput in interface SmartCache<K,V>key - Keyvalue - Valuekey or nullpublic V remove(K key)
SmartCacheremove in interface SmartCache<K,V>key - Keypublic void clear()
clear in interface SmartCache<K,V>public int size()
size in interface SmartCache<K,V>