Package ru.tinkoff.kora.cache
Interface CacheLoader<K,V>
public interface CacheLoader<K,V>
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> CacheLoader<K, V> Create default loadable cache implementation for async operationstatic <K,V> CacheLoader<K, V> async(Function<K, reactor.core.publisher.Mono<V>> loader, Function<Collection<K>, reactor.core.publisher.Mono<Map<K, V>>> loaderMany) static <K,V> CacheLoader<K, V> blocking(Function<K, V> loader, ExecutorService executor) static <K,V> CacheLoader<K, V> blocking(Function<K, V> loader, Function<Collection<K>, Map<K, V>> loaderMany, ExecutorService executor) Create default loadable cache implementation for blocking operationload(Collection<K> keys) Computes or retrieves the value corresponding tokey.Computes or retrieves the value corresponding tokey.loadAsync(Collection<K> keys) Computes or retrieves the value corresponding tokeyasynchronously.reactor.core.publisher.Mono<V>Computes or retrieves the value corresponding tokeyasynchronously.static <K,V> CacheLoader<K, V> nonBlocking(Function<K, V> loader) static <K,V> CacheLoader<K, V> nonBlocking(Function<K, V> loader, Function<Collection<K>, Map<K, V>> loaderMany) Create default loadable cache implementation for non-blocking operation
-
Method Details
-
load
Computes or retrieves the value corresponding tokey.- Parameters:
key- to look value for- Returns:
- value associated with key
-
load
Computes or retrieves the value corresponding tokey.- Parameters:
keys- to look value for- Returns:
- value associated with key
-
loadAsync
Computes or retrieves the value corresponding tokeyasynchronously.- Parameters:
key- to look value for- Returns:
- value associated with key or
Mono.empty()
-
loadAsync
Computes or retrieves the value corresponding tokeyasynchronously.- 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 keyV- Cache value- Parameters:
executor- Executor to submit load task on async callloader- Blocking load operationloaderMany- Blocking load for multiple keys- Returns:
- default loadable cache instance
-
nonBlocking
-
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 keyV- 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 keyV- 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)
-