Interface Cache<K,V>
public interface Cache<K,V>
A cache from keys to values.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> Cache <K, V> bounded(int capacity) Returns new bounded cache.computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) Returns the cached value associated with the providedkey.Returns the cached value associated with the providedkeyif present, ornullotherwise.voidPuts thevalueinto the cache for thekey.voidRemoves a value forkeyif present.static <K,V> Cache <K, V> weak()Returns new unbounded cache
-
Method Details
-
weak
Returns new unbounded cacheKeys are referenced weakly and compared using identity comparison, not
Object.equals(Object). -
bounded
Returns new bounded cache.Both keys and values are strongly referenced.
-
computeIfAbsent
Returns the cached value associated with the providedkey. If no value is cached yet, computes the value usingmappingFunction, stores the result, and returns it. -
get
Returns the cached value associated with the providedkeyif present, ornullotherwise. -
put
Puts thevalueinto the cache for thekey. -
remove
Removes a value forkeyif present.
-