Package org.forgerock.openig.tools.cache
Class CaffeineAsyncCache.Builder<K,V,E extends Exception>
java.lang.Object
org.forgerock.openig.tools.cache.CaffeineAsyncCache.Builder<K,V,E>
- Type Parameters:
K
- type of the keyV
- type of the cached valueE
- type of the promise exception
- Enclosing class:
- CaffeineAsyncCache<K,
V, E extends Exception>
A builder for a
CaffeineAsyncCache
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAsyncCache<K,
V, E> Builds theCaffeineAsyncCache
.evictionListener
(com.github.benmanes.caffeine.cache.RemovalListener<? super K, ? super V> evictionListener) Sets aRemovalListener
to be called when items are evicted from the cache.Sets theExecutor
to use for the cache.expireAfter
(com.github.benmanes.caffeine.cache.Expiry<K, V> expiry) Sets the expiry of items in the cache.expireAfterWrite
(long value, TimeUnit unit) Sets the expiry of items in the cache after they are written.maximumSize
(long maximumSize) Sets the maximum size of the cache.monitoring
(org.forgerock.monitoring.api.instrument.MeterRegistry registry, String name) Sets up cache stats monitoring.removalListener
(com.github.benmanes.caffeine.cache.RemovalListener<? super K, ? super V> removalListener) Sets aRemovalListener
to be called when items are removed from the cache.ticker
(com.github.benmanes.caffeine.cache.Ticker ticker) Sets the ticker to use for the cache.
-
Constructor Details
-
Builder
public Builder()Constructs a newCaffeineAsyncCache.Builder
.
-
-
Method Details
-
monitoring
public CaffeineAsyncCache.Builder<K,V, monitoringE> (org.forgerock.monitoring.api.instrument.MeterRegistry registry, String name) Sets up cache stats monitoring.- Parameters:
registry
- the registry to usename
- the name of the cache stats meter in the registry- Returns:
- this builder
-
ticker
Sets the ticker to use for the cache.- Parameters:
ticker
- the ticker to use- Returns:
- this builder
-
maximumSize
Sets the maximum size of the cache.- Parameters:
maximumSize
- the maximum size of the cache- Returns:
- this builder
-
expireAfter
public CaffeineAsyncCache.Builder<K,V, expireAfterE> (com.github.benmanes.caffeine.cache.Expiry<K, V> expiry) Sets the expiry of items in the cache.- Parameters:
expiry
- the expiry of items in the cache- Returns:
- this builder
-
expireAfterWrite
Sets the expiry of items in the cache after they are written.- Parameters:
value
- the duration after which items are expiredunit
- the time unit of the duration- Returns:
- this builder
-
removalListener
public CaffeineAsyncCache.Builder<K,V, removalListenerE> (com.github.benmanes.caffeine.cache.RemovalListener<? super K, ? super V> removalListener) Sets aRemovalListener
to be called when items are removed from the cache.- Parameters:
removalListener
- the listener to be called when items are removed from the cache- Returns:
- this builder
-
evictionListener
public CaffeineAsyncCache.Builder<K,V, evictionListenerE> (com.github.benmanes.caffeine.cache.RemovalListener<? super K, ? super V> evictionListener) Sets aRemovalListener
to be called when items are evicted from the cache.- Parameters:
evictionListener
- the listener to be called when items are evicted from the cache- Returns:
- this builder
-
executor
Sets theExecutor
to use for the cache.- Parameters:
executor
- the executor to use- Returns:
- this builder
-
build
Builds theCaffeineAsyncCache
.- Parameters:
exceptionClass
- the exception class to use for the promises- Returns:
- the built
AsyncCache
-