LoadingCache or
AsyncLoadingCache.
Most implementations will only need to implement load. Other methods may be
overridden as desired.
Usage example:
CacheLoader<Key, Graph> loader = key -> createExpensiveGraph(key);
LoadingCache<Key, Graph> cache = Caffeine.newBuilder().build(loader);
| Modifier and Type | Method and Description |
|---|---|
| public default CompletableFuture | Returns: the future value associated withkeythe non-null key whose value should be loaded key, Executor the executor that asynchronously loads the entry executor)Implements com. key.
|
| public default CompletableFuture | Returns: a future containing the map from each key inkeys to the value associated with
that key; may not contain null valuesthe unique, non-null keys whose values should be loaded keys, Executor the executor that with asynchronously loads the entries executor)Overrides default com. keys.
|
| public default CompletableFuture | Returns: a future containing the new value associated withkey, or containing
null if the mapping is to be removedthe non-null key whose value should be loaded key, V the non-null old value corresponding to oldValue, Executor keythe executor with which the entry is asynchronously loaded executor)Overrides default com. key.
|
| public static < the key type K, the value type V> CacheLoader | Returns: a cache loader that delegates to the suppliedmappingFunctionthe function to compute the values mappingFunction)Hides com. |
| public @Nullable V | Returns: the value associated withkey or null if not foundthe non-null key whose value should be loaded key)Computes or retrieves the value corresponding to |
| public default Map | |
| public default @Nullable V | Returns: the new value associated withkey, or null if the mapping is to be
removedthe non-null key whose value should be loaded key, V the non-null old value corresponding to oldValue)keyComputes or retrieves a replacement value corresponding to an already-cached |
| asyncLoad | back to summary |
|---|---|
| public default CompletableFuture Implements com. Asynchronously computes or retrieves the value corresponding to
| |
| asyncLoadAll | back to summary |
|---|---|
| public default CompletableFuture Overrides default com. Asynchronously computes or retrieves the values corresponding to
If the returned map doesn't contain all requested
This method should be overridden when bulk retrieval is significantly more efficient than many
individual lookups. Note that Warning loading must not attempt to update any mappings of this cache directly.
| |
| asyncReload | back to summary |
|---|---|
| public default CompletableFuture Overrides default com. Asynchronously computes or retrieves a replacement value corresponding to an already-cached
Warning loading must not attempt to update any mappings of this cache directly or block waiting for other cache operations to complete. Note all exceptions thrown by this method will be logged and then swallowed.
| |
| bulk | back to summary |
|---|---|
| public static <K, V> CacheLoader Hides com. Returns a cache loader that delegates to the supplied mapping function for retrieving the
values. Note that Usage example:
| |
| load | back to summary |
|---|---|
| public @Nullable V load(K key) throws Exception Computes or retrieves the value corresponding to Warning loading must not attempt to update any mappings of this cache directly.
| |
| loadAll | back to summary |
|---|---|
| public default Map Computes or retrieves the values corresponding to
If the returned map doesn't contain all requested
This method should be overridden when bulk retrieval is significantly more efficient than many
individual lookups. Note that Warning loading must not attempt to update any mappings of this cache directly.
| |
| reload | back to summary |
|---|---|
| public default @Nullable V reload(K key, V oldValue) throws Exception Computes or retrieves a replacement value corresponding to an already-cached Warning loading must not attempt to update any mappings of this cache directly or block waiting for other cache operations to complete. Note all exceptions thrown by this method will be logged and then swallowed.
| |