- Type Parameters:
K- type of the keys
V- type of the values
- All Known Subinterfaces:
- All Known Implementing Classes:
public interface MemoizeCache<K,V>
Represents a memoize cache with its essential methods
Nested Class Summary
Nested Classes Modifier and Type Interface Description
static interfaceRepresents a provider used to create value
Modifier and Type Method Description
()Invoked when some of the held SoftReferences have been evicted by the garbage collector and so should be removed from the cache.
K key)(Gets a value from the cache
K key, MemoizeCache.ValueProvider<? super K,? extends V> valueProvider)(Try to get the value from cache.
K key, V value)(Associates the specified value with the specified key in the cache.
putAssociates the specified value with the specified key in the cache.
key- key with which the specified value is to be associated
value- value to be associated with the specified key
- null, or the old value if the key associated with the specified key.
getGets a value from the cache
key- the key whose associated value is to be returned
- the value, or null, if it does not exist.
getAndPutTry to get the value from cache. If not found, create the value by
MemoizeCache.ValueProviderand put it into the cache, at last return the value.
valueProvider- provide the value if the associated value not found
- the cached value
cleanUpNullReferencesvoid cleanUpNullReferences()Invoked when some of the held SoftReferences have been evicted by the garbage collector and so should be removed from the cache. The implementation must ensure that concurrent invocations of all methods on the cache may occur from other threads and thus should protect any shared resources.