Interface ReadThroughCache<K,V>
- Type Parameters:
K
- the type of the cache keyV
- the type of the cache value
- All Known Implementing Classes:
ReadThroughAtlassianCache
,ReadThroughEntityCache
public interface ReadThroughCache<K,V>
A simple cache interface that supports the use of read-through operations.
- Since:
- 7.5
-
Method Summary
Modifier and TypeMethodDescriptiondefault V
Retrieve the value for the given key.Retrieve the value for the given key.Retrieves multiple values for the given keys.void
Removs the cache entry for the given key.void
Removes all cache entries.
-
Method Details
-
get
Retrieve the value for the given key. If the value is in the cache this will be returned, else the given delegate will be called to retrieve the value. If the delegate returns a value, it will be placed in the cache and returned, else nothing will be placed in the cache andOptional.empty()
will be returned.- Parameters:
cacheKey
- the key to resolve in the cachedelegateLoader
- ASupplier
which will be called if there is no value in the cache (may return null).- Returns:
- the cached value, or the value which was loaded from the supplier (may be null)
-
get
Retrieve the value for the given key. If the value is in the cache this will be returned, else the given delegate will be called to retrieve the value. If the delegate returns a value, and if it passes the given filter, it will be placed in the cache and returned. If the filter rejects the value, nothing will be placed in the cache but the value will be returned from the method.- Parameters:
cacheKey
- the key to resolve in the cachedelegateLoader
- ASupplier
which will be called if there is no value in the cache (may return null).valueTester
- APredicate
that will be used to test the validity of any value in the cache or loaded from the supplier- Returns:
- the cached value, or the value which was loaded from the supplier (may be null)
-
getBulk
Retrieves multiple values for the given keys. Any entries not already present in the cache will be supplied via the delegate loader. -
remove
Removs the cache entry for the given key. -
removeAll
void removeAll()Removes all cache entries.
-