Class LruCache<K,V>
java.lang.Object
com.weirddev.testme.intellij.cache.LruCache<K,V>
- All Implemented Interfaces:
Cache<K,
V>
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetOrCompute
(K key, Supplier<V> valueSupplier) Retrieves an item from the cache by its key.
-
Constructor Details
-
LruCache
public LruCache(int maxSize)
-
-
Method Details
-
getOrCompute
Description copied from interface:Cache
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.- Specified by:
getOrCompute
in interfaceCache<K,
V> - 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
- Specified by:
getUsageStats
in interfaceCache<K,
V>
-