Package org.forgerock.openig.tools.cache
Interface AsyncCache<K,V,E extends Exception>
- Type Parameters:
K
- type of the keyV
- type of the cached valueE
- type of the promise exception
- All Known Implementing Classes:
CaffeineAsyncCache
public interface AsyncCache<K,V,E extends Exception>
A Promise-based cache interface that provides asynchronous access to a cache implementation.
-
Method Summary
Modifier and TypeMethodDescriptionReturns a promise that will be completed with the value associated with the key in this cache, or with an exception if the case of any errors.getIfPresent
(K key) Return anOptional
promise of the value which will be empty if the key is not present in the cache.void
Synchronously clean up the entire cache.void
synchronousInvalidate
(K key) Synchronously invalidates the cache entry for the given key.void
Synchronously invalidates all the cache entries.void
synchronousInvalidateAll
(Iterable<? extends K> keys) Synchronously invalidates all the cache entries for the given keys.
-
Method Details
-
get
Returns a promise that will be completed with the value associated with the key in this cache, or with an exception if the case of any errors. If the key is not present in the cache then the value will first be obtained by invoking the supplied mapping function.- Parameters:
key
- the key to look upasyncValueSupplier
- the asynchronous supplier to obtain the value from if it is not already present in the cache.- Returns:
- a promise that will be completed with the value associated with the key in this cache, or with an exception if the case of any errors.
-
getIfPresent
Return anOptional
promise of the value which will be empty if the key is not present in the cache.- Parameters:
key
- the key to look up in the cache- Returns:
- an
Optional
promise of the value which will be empty if the key is not present in the cache
-
synchronousCleanUp
void synchronousCleanUp()Synchronously clean up the entire cache. -
synchronousInvalidate
Synchronously invalidates the cache entry for the given key.- Parameters:
key
- the key to invalidate
-
synchronousInvalidateAll
Synchronously invalidates all the cache entries for the given keys.- Parameters:
keys
- the keys to invalidate
-
synchronousInvalidateAll
void synchronousInvalidateAll()Synchronously invalidates all the cache entries.
-