Interface Cache<K,V>
- All Known Implementing Classes:
LruCache
public interface Cache<K,V>
-
Method Summary
Modifier and TypeMethodDescriptiongetOrCompute
(K key, Supplier<V> valueSupplier) Retrieves an item from the cache by its key.
-
Method Details
-
getOrCompute
Retrieves an item from the cache by its key. If the item is not present, the supplied lambda expression is used to compute the value and store it in the cache.- Parameters:
key
- the key of the item to retrieve.valueSupplier
- a lambda expression or method reference that supplies the value if it's missing.- Returns:
- the value associated with the key, either from the cache or computed by the supplied lambda.
-
getUsageStats
LruCache.CacheStats getUsageStats()
-