@ThreadSafe
public interface Cache<K,V>
The cache allows for concurrent access and modification to its content and automatically controls the amount of entries in the cache to stay within configured resource limits.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
Cache.Shrinkable<V>
An interface that marks an object that can be reduced in size instead of being evicted
completely.
|
| Modifier and Type | Method and Description |
|---|---|
V |
computeIfAbsent(K key,
java.util.function.Function<K,V> loadingFunction)
Looks up the specified key and returns the associated value.
|
java.lang.String |
describeStats()
Returns a string containing caching statistics.
|
V |
peek(K key)
Looks up the specified key returning
null if the value is not within the cache. |
void |
put(K key,
V value)
Inserts a new value associated with the given key or updates an existing association of the
same key with the new value.
|
void |
remove(K key)
Removes the mapping for a key from the cache if it is present.
|
@Nullable V peek(K key)
null if the value is not within the cache.V computeIfAbsent(K key, java.util.function.Function<K,V> loadingFunction)
If the key is not present in the cache, the specified function will be used to load and populate the cache.
void put(K key, V value)
void remove(K key)
java.lang.String describeStats()