Interface CacheLoader<K,V>


public interface CacheLoader<K,V>
  • Method Details

    • load

      @Nullable V load(@Nonnull K key)
      Computes or retrieves the value corresponding to key.
      Parameters:
      key - to look value for
      Returns:
      value associated with key
    • load

      @Nullable Map<K,V> load(@Nonnull Collection<K> keys)
      Computes or retrieves the value corresponding to key.
      Parameters:
      keys - to look value for
      Returns:
      value associated with key
    • loadAsync

      @Nonnull reactor.core.publisher.Mono<V> loadAsync(@Nonnull K key)
      Computes or retrieves the value corresponding to key asynchronously.
      Parameters:
      key - to look value for
      Returns:
      value associated with key or Mono.empty()
    • loadAsync

      reactor.core.publisher.Mono<Map<K,V>> loadAsync(@Nonnull Collection<K> keys)
      Computes or retrieves the value corresponding to key asynchronously.
      Parameters:
      keys - to look value for
      Returns:
      value associated with key or Mono.empty()
    • blocking

      @Nonnull static <K, V> CacheLoader<K,V> blocking(@Nonnull Function<K,V> loader, @Nonnull ExecutorService executor)
    • blocking

      @Nonnull static <K, V> CacheLoader<K,V> blocking(@Nonnull Function<K,V> loader, @Nonnull Function<Collection<K>,Map<K,V>> loaderMany, @Nonnull ExecutorService executor)
      Create default loadable cache implementation for blocking operation
      Type Parameters:
      K - Cache key
      V - Cache value
      Parameters:
      executor - Executor to submit load task on async call
      loader - Blocking load operation
      loaderMany - Blocking load for multiple keys
      Returns:
      default loadable cache instance
    • nonBlocking

      @Nonnull static <K, V> CacheLoader<K,V> nonBlocking(@Nonnull Function<K,V> loader)
    • nonBlocking

      @Nonnull static <K, V> CacheLoader<K,V> nonBlocking(@Nonnull Function<K,V> loader, @Nonnull Function<Collection<K>,Map<K,V>> loaderMany)
      Create default loadable cache implementation for non-blocking operation
      Type Parameters:
      K - Cache key
      V - Cache value
      Parameters:
      loader - Some long computation
      Returns:
      default loadable cache instance
    • async

      @Nonnull static <K, V> CacheLoader<K,V> async(@Nonnull Function<K,reactor.core.publisher.Mono<V>> loader)
      Create default loadable cache implementation for async operation
      Type Parameters:
      K - Cache key
      V - Cache value
      Parameters:
      loader - Async
      Returns:
      default loadable cache instance
    • async

      @Nonnull static <K, V> CacheLoader<K,V> async(@Nonnull Function<K,reactor.core.publisher.Mono<V>> loader, @Nonnull Function<Collection<K>,reactor.core.publisher.Mono<Map<K,V>>> loaderMany)