Interface Cache<K,V>
-
public interface Cache<K,V>A cache from keys to values.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description VcomputeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)Returns the cached value associated with the providedkey.Vget(K key)Returns the cached value associated with the providedkeyif present, ornullotherwise.static CacheBuildernewBuilder()Returns a newCacheBuilderto configure aCache.voidput(K key, V value)Puts thevalueinto the cache for thekey.voidremove(K key)Removes a value forkeyif present.
-
-
-
Method Detail
-
newBuilder
static CacheBuilder newBuilder()
Returns a newCacheBuilderto configure aCache.
-
computeIfAbsent
V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
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
V get(K key)
Returns the cached value associated with the providedkeyif present, ornullotherwise.
-
remove
void remove(K key)
Removes a value forkeyif present.
-
-