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 key
V - type of the cached value
E - 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.
  • Method Details

    • get

      public Promise<V,E> get(K key, Supplier<Promise<V,E>> asyncValueSupplier)
      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 interface AsyncCache<K,V,E extends Exception>
      Parameters:
      key - the key to look up
      asyncValueSupplier - 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

      public Optional<Promise<V,E>> getIfPresent(K key)
      Description copied from interface: AsyncCache
      Return an Optional promise of the value which will be empty if the key is not present in the cache.
      Specified by:
      getIfPresent in interface AsyncCache<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 interface AsyncCache<K,V,E extends Exception>
    • synchronousInvalidate

      public void synchronousInvalidate(K key)
      Description copied from interface: AsyncCache
      Synchronously invalidates the cache entry for the given key.
      Specified by:
      synchronousInvalidate in interface AsyncCache<K,V,E extends Exception>
      Parameters:
      key - the key to invalidate
    • synchronousInvalidateAll

      public void synchronousInvalidateAll(Iterable<? extends K> keys)
      Description copied from interface: AsyncCache
      Synchronously invalidates all the cache entries for the given keys.
      Specified by:
      synchronousInvalidateAll in interface AsyncCache<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 interface AsyncCache<K,V,E extends Exception>