Package org.forgerock.openig.tools.cache
Class CaffeineAsyncCache<K,V,E extends Exception>
java.lang.Object
org.forgerock.openig.tools.cache.CaffeineAsyncCache<K,V,E>
- Type Parameters:
K
- type of the keyV
- type of the cached valueE
- type of the promise exception
- All Implemented Interfaces:
AsyncCache<K,
V, E>
public final class CaffeineAsyncCache<K,V,E extends Exception>
extends Object
implements AsyncCache<K,V,E>
Provides a Caffeine-based implementation of the
AsyncCache
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
CaffeineAsyncCache.Builder<K,
V, E extends Exception> A builder for aCaffeineAsyncCache
. -
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
Description copied from interface:AsyncCache
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.- Specified by:
get
in interfaceAsyncCache<K,
V, E extends Exception> - 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
Description copied from interface:AsyncCache
Return anOptional
promise of the value which will be empty if the key is not present in the cache.- Specified by:
getIfPresent
in interfaceAsyncCache<K,
V, E extends Exception> - 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
public void synchronousCleanUp()Description copied from interface:AsyncCache
Synchronously clean up the entire cache.- Specified by:
synchronousCleanUp
in interfaceAsyncCache<K,
V, E extends Exception>
-
synchronousInvalidate
Description copied from interface:AsyncCache
Synchronously invalidates the cache entry for the given key.- Specified by:
synchronousInvalidate
in interfaceAsyncCache<K,
V, E extends Exception> - Parameters:
key
- the key to invalidate
-
synchronousInvalidateAll
Description copied from interface:AsyncCache
Synchronously invalidates all the cache entries for the given keys.- Specified by:
synchronousInvalidateAll
in interfaceAsyncCache<K,
V, E extends Exception> - Parameters:
keys
- the keys to invalidate
-
synchronousInvalidateAll
public void synchronousInvalidateAll()Description copied from interface:AsyncCache
Synchronously invalidates all the cache entries.- Specified by:
synchronousInvalidateAll
in interfaceAsyncCache<K,
V, E extends Exception>
-