Interface AsyncCache<K,V,E extends Exception>

Type Parameters:
K - type of the key
V - type of the cached value
E - 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 Details

    • get

      Promise<V,E> get(K key, Supplier<Promise<V,E>> asyncValueSupplier)
      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 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

      Optional<Promise<V,E>> getIfPresent(K key)
      Return an Optional 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

      void synchronousInvalidate(K key)
      Synchronously invalidates the cache entry for the given key.
      Parameters:
      key - the key to invalidate
    • synchronousInvalidateAll

      void synchronousInvalidateAll(Iterable<? extends K> keys)
      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.