- All Known Implementing Classes:
Cache0,Cache1,CacheCaffeine,CacheSimple,CacheWrapper
public interface Cache<Key,Value>
An abstraction of a cache for basic use.
For more complex configuration of the cache, use the cache builder of the implementation of choice.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Key key) Does the cache contain the key?Get from cache; if not present, call theFunctionto fill the cache slot.getIfPresent(Key key) Get from cache - or return null.default ValueDeprecated.booleanisEmpty()keys()Iterate over all keys.voidInsert into the cachevoidRemove from cache - return true if key referenced an entrylongsize()Current size of cachedefault CacheInfostats()Cache statistics (not supported by all caches)
-
Method Details
-
containsKey
Does the cache contain the key? -
getIfPresent
Get from cache - or return null. -
getOrFill
Deprecated.Get from cache; if not present, call theCallableto try to fill the cache. This operation should be atomic. -
get
Get from cache; if not present, call theFunctionto fill the cache slot. This operation should be atomic. -
put
Insert into the cache -
remove
Remove from cache - return true if key referenced an entry -
keys
Iterate over all keys. Iterating over the keys requires the caller be thread-safe. -
isEmpty
boolean isEmpty() -
clear
void clear() -
size
long size()Current size of cache -
stats
Cache statistics (not supported by all caches)
-
get(Object, Function)