Package io.ocfl.core.cache
Interface Cache<K,V>
- Type Parameters:
K
- type of cache keyV
- type of cache value
- All Known Implementing Classes:
CaffeineCache
,NoOpCache
public interface Cache<K,V>
Extension point that allows the OCFL repository to use any number of different cache implementations so long as they
conform to this interface.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if the cache contains the specified keyRetrieves a value from the cache.void
invalidate
(K key) Invalidates the key in the cache.void
Invalidates the entire cachevoid
Inserts a value into the cache.
-
Method Details
-
get
Retrieves a value from the cache. If it doesn't exist, the loader is called to load the object, which is then cached and returned.- Parameters:
key
- to lookup in the cacheloader
- function to call to load the object if it's not found- Returns:
- the object that maps to the key
-
put
Inserts a value into the cache.- Parameters:
key
- keyvalue
- value
-
invalidate
Invalidates the key in the cache.- Parameters:
key
- key
-
invalidateAll
void invalidateAll()Invalidates the entire cache -
contains
Returns true if the cache contains the specified key- Parameters:
key
- key- Returns:
- true if the cache contains the key
-