Package edu.wisc.library.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:
CaffeineCache
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancontains(K key)Returns true if the cache contains the specified keyVget(K key, Function<K,V> loader)Retrieves a value from the cache.voidinvalidate(K key)Invalidates the key in the cache.voidput(K key, V value)Inserts a value into the cache.
-
-
-
Method Detail
-
get
V get(K key, Function<K,V> loader)
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
-
invalidate
void invalidate(K key)
Invalidates the key in the cache.- Parameters:
key- key
-
contains
boolean contains(K key)
Returns true if the cache contains the specified key- Parameters:
key- key- Returns:
- true if the cache contains the key
-
-