- Type Parameters:
K- type of the keys
V- type of the values
- All Known Subinterfaces:
- All Known Implementing Classes:
public interface MemoizeCache<K,
Represents a memoize cache with its essential methods
Nested Class Summary
Method SummaryModifier and TypeMethodDescription
voidInvoked when some of the held SoftReferences have been evicted by the garbage collector and so should be removed from the cache.Gets a value from the cache
default VTry to get the value from cache.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.
key- the key to look up
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.