Class BoundedLocalCache.BoundedLocalAsyncLoadingCache.AsyncLoader<K,V>
- java.lang.Object
-
- com.github.benmanes.caffeine.cache.BoundedLocalCache.BoundedLocalAsyncLoadingCache.AsyncLoader<K,V>
-
- All Implemented Interfaces:
AsyncCacheLoader<K,V>,CacheLoader<K,V>
- Enclosing class:
- BoundedLocalCache.BoundedLocalAsyncLoadingCache<K,V>
static final class BoundedLocalCache.BoundedLocalAsyncLoadingCache.AsyncLoader<K,V> extends java.lang.Object implements CacheLoader<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.concurrent.Executorexecutor(package private) AsyncCacheLoader<? super K,V>loader
-
Constructor Summary
Constructors Constructor Description AsyncLoader(AsyncCacheLoader<? super K,V> loader, Caffeine<?,?> builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<V>asyncReload(K key, V oldValue, java.util.concurrent.Executor executor)Asynchronously computes or retrieves a replacement value corresponding to an already-cachedkey.Vload(K key)Computes or retrieves the value corresponding tokey.Vreload(K key, V oldValue)Computes or retrieves a replacement value corresponding to an already-cachedkey.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.benmanes.caffeine.cache.CacheLoader
asyncLoad, asyncLoadAll, loadAll
-
-
-
-
Field Detail
-
loader
final AsyncCacheLoader<? super K,V> loader
-
executor
final java.util.concurrent.Executor executor
-
-
Constructor Detail
-
AsyncLoader
AsyncLoader(AsyncCacheLoader<? super K,V> loader, Caffeine<?,?> builder)
-
-
Method Detail
-
load
public V load(K key)
Description copied from interface:CacheLoaderComputes or retrieves the value corresponding tokey.Warning: loading must not attempt to update any mappings of this cache directly.
- Specified by:
loadin interfaceCacheLoader<K,V>- Parameters:
key- the non-null key whose value should be loaded- Returns:
- the value associated with
keyornullif not found
-
reload
public V reload(K key, V oldValue)
Description copied from interface:CacheLoaderComputes or retrieves a replacement value corresponding to an already-cachedkey. If the replacement value is not found then the mapping will be removed ifnullis returned. This method is called when an existing cache entry is refreshed byCaffeine.refreshAfterWrite(java.time.Duration), or through a call toLoadingCache.refresh(K).Note: all exceptions thrown by this method will be logged and then swallowed.
- Specified by:
reloadin interfaceCacheLoader<K,V>- Parameters:
key- the non-null key whose value should be loadedoldValue- the non-null old value corresponding tokey- Returns:
- the new value associated with
key, ornullif the mapping is to be removed
-
asyncReload
public java.util.concurrent.CompletableFuture<V> asyncReload(K key, V oldValue, java.util.concurrent.Executor executor)
Description copied from interface:CacheLoaderAsynchronously computes or retrieves a replacement value corresponding to an already-cachedkey. If the replacement value is not found then the mapping will be removed ifnullis computed. This method is called when an existing cache entry is refreshed byCaffeine.refreshAfterWrite(java.time.Duration), or through a call toLoadingCache.refresh(K).Note: all exceptions thrown by this method will be logged and then swallowed.
- Specified by:
asyncReloadin interfaceAsyncCacheLoader<K,V>- Specified by:
asyncReloadin interfaceCacheLoader<K,V>- Parameters:
key- the non-null key whose value should be loadedoldValue- the non-null old value corresponding tokeyexecutor- the executor with which the entry is asynchronously loaded- Returns:
- a future containing the new value associated with
key, or containingnullif the mapping is to be removed
-
-