Interface AsyncCache<C>

Type Parameters:
C - The native cache implementation
All Superinterfaces:
Cache<C>
All Known Implementing Classes:
DelegatingAsyncBlockingCache, DelegatingAsyncCache, HazelcastAsyncCache, InfinispanAsyncCache

public interface AsyncCache<C> extends Cache<C>

A cache implementation that supports async non-blocking caching operations.

Since:
1.0
Author:
Graeme Rocher
  • Method Details

    • get

      <T> CompletableFuture<Optional<T>> get(Object key, io.micronaut.core.type.Argument<T> requiredType)
      Resolve the given value for the given key.
      Type Parameters:
      T - The concrete type
      Parameters:
      key - The cache key
      requiredType - The required type
      Returns:
      An optional containing the value if it exists and is able to be converted to the specified type
    • get

      <T> CompletableFuture<T> get(Object key, io.micronaut.core.type.Argument<T> requiredType, Supplier<T> supplier)
      Resolve the given value for the given key. If the value is not found the specified Supplier will be invoked and the return value cached.
      Type Parameters:
      T - The concrete type
      Parameters:
      key - The cache key
      requiredType - The required type
      supplier - The supplier that should be invoked if the value is not found
      Returns:
      An optional containing the value if it exists and is able to be converted to the specified type
    • putIfAbsent

      <T> CompletableFuture<Optional<T>> putIfAbsent(Object key, T value)

      Cache the specified value using the specified key if it is not already present.

      Type Parameters:
      T - The concrete type
      Parameters:
      key - The key with which the specified value is to be associated
      value - The value to be associated with the specified key
      Returns:
      An optional of the existing value or Optional.empty() if the specified value parameter was cached
    • put

      Cache the specified value using the specified key.

      Parameters:
      key - The key with which the specified value is to be associated
      value - The value to be associated with the specified key
      Returns:
      A future with a boolean indicating whether the operation was successful or not
    • invalidate

      CompletableFuture<Boolean> invalidate(Object key)
      Invalidate the value for the given key.
      Parameters:
      key - The key to invalid
      Returns:
      A future with a boolean indicating whether the operation was succesful or not
    • invalidateAll

      CompletableFuture<Boolean> invalidateAll()
      Invalidate all cached values within this cache.
      Returns:
      A future with a boolean indicating whether the operation was succesful or not
    • get

      default <T> CompletableFuture<Optional<T>> get(Object key, Class<T> requiredType)
      Resolve the given value for the given key.
      Type Parameters:
      T - The concrete type
      Parameters:
      key - The cache key
      requiredType - The required type
      Returns:
      An optional containing the value if it exists and is able to be converted to the specified type
    • get

      default <T> CompletableFuture<T> get(Object key, Class<T> requiredType, Supplier<T> supplier)
      Resolve the given value for the given key. If the value is not found the specified Supplier will be invoked and the return value cached.
      Type Parameters:
      T - The concrete type
      Parameters:
      key - The cache key
      requiredType - The required type
      supplier - The supplier that should be invoked if the value is not found
      Returns:
      An optional containing the value if it exists and is able to be converted to the specified type