Interface Cache<K,V>
- Type Parameters:
K- the type of keys maintained by this cacheV- the type of mapped values
- All Known Implementing Classes:
CaffeineCache
public interface Cache<K,V>
A semi-persistent mapping from keys to values.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionFetches the key from the cache.static <K,V> Cache <K, V> newCache(int timeout) Creates a new cache with the specified timeout.voidStores a binding for the key and the value in the cache.voidRemoves the binding for the key from the cache.intsize()Returns the number of bindings in this cache.
-
Method Details
-
newCache
Creates a new cache with the specified timeout.The cache implementation is obtained using
ServiceLoader. To create your own implementation, implementCacheSupplierand register it using the/META-INF/services/waffle.util.cache.CacheSupplierfile on your classpath.- Type Parameters:
K- the type of keys maintained by this cacheV- the type of mapped values- Parameters:
timeout- timeout in seconds- Returns:
- a new cache
- Throws:
NoSuchElementException- if no cache can be instantiated, useThrowable.getSuppressed()to obtain details.
-
get
-
put
-
remove
Removes the binding for the key from the cache.- Parameters:
key- the key- See Also:
-
size
int size()Returns the number of bindings in this cache.- Returns:
- the size
- See Also:
-