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 key
V - type of the cached value
E - type of the promise exception
Enclosing class:
CaffeineAsyncCache<K,V,E extends Exception>

public static final class CaffeineAsyncCache.Builder<K,V,E extends Exception> extends Object
A builder for a CaffeineAsyncCache.
  • Constructor Details

  • Method Details

    • monitoring

      public CaffeineAsyncCache.Builder<K,V,E> monitoring(org.forgerock.monitoring.api.instrument.MeterRegistry registry, String name)
      Sets up cache stats monitoring.
      Parameters:
      registry - the registry to use
      name - the name of the cache stats meter in the registry
      Returns:
      this builder
    • ticker

      public CaffeineAsyncCache.Builder<K,V,E> ticker(com.github.benmanes.caffeine.cache.Ticker ticker)
      Sets the ticker to use for the cache.
      Parameters:
      ticker - the ticker to use
      Returns:
      this builder
    • maximumSize

      public CaffeineAsyncCache.Builder<K,V,E> maximumSize(long 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,E> expireAfter(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

      public CaffeineAsyncCache.Builder<K,V,E> expireAfterWrite(long value, TimeUnit unit)
      Sets the expiry of items in the cache after they are written.
      Parameters:
      value - the duration after which items are expired
      unit - the time unit of the duration
      Returns:
      this builder
    • removalListener

      public CaffeineAsyncCache.Builder<K,V,E> removalListener(com.github.benmanes.caffeine.cache.RemovalListener<? super K,? super V> removalListener)
      Sets a RemovalListener 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,E> evictionListener(com.github.benmanes.caffeine.cache.RemovalListener<? super K,? super V> evictionListener)
      Sets a RemovalListener 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

      public CaffeineAsyncCache.Builder<K,V,E> executor(Executor executor)
      Sets the Executor to use for the cache.
      Parameters:
      executor - the executor to use
      Returns:
      this builder
    • build

      public AsyncCache<K,V,E> build(Class<E> exceptionClass)
      Builds the CaffeineAsyncCache.
      Parameters:
      exceptionClass - the exception class to use for the promises
      Returns:
      the built AsyncCache