public interface MemoizeCache<K, V>
Represents a memoize cache with its essential methods
K
- type of the keysV
- type of the valuesModifiers | Name | Description |
---|---|---|
interface | MemoizeCache.ValueProvider | Represents a provider used to create value |
Type Params | Return Type | Name and description |
---|---|---|
public void |
cleanUpNullReferences() Invoked when some of the held SoftReferences have been evicted by the garbage collector and so should be removed from the cache. | |
public V |
get(K key) Gets a value from the cache | |
public V |
getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider) Try to get the value from cache. | |
public V |
put(K key, V value) Associates the specified value with the specified key in the cache. |
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.
Gets a value from the cache
key
- the key whose associated value is to be returnedTry to get the value from cache. If not found, create the value by ValueProvider and put it into the cache, at last return the value.
valueProvider
- provide the value if the associated value not foundAssociates the specified value with the specified key in the cache.
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/org/codehaus/groovy/runtime/memoize/MemoizeCache.html