Class BoundedLocalCache.BoundedLocalAsyncLoadingCache.AsyncLoader<K,​V>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.concurrent.Executor executor  
      (package private) AsyncCacheLoader<? super K,​V> loader  
    • 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-cached key.
      V load​(K key)
      Computes or retrieves the value corresponding to key.
      V reload​(K key, V oldValue)
      Computes or retrieves a replacement value corresponding to an already-cached key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • executor

        final java.util.concurrent.Executor executor
    • Method Detail

      • load

        public V load​(K key)
        Description copied from interface: CacheLoader
        Computes or retrieves the value corresponding to key.

        Warning: loading must not attempt to update any mappings of this cache directly.

        Specified by:
        load in interface CacheLoader<K,​V>
        Parameters:
        key - the non-null key whose value should be loaded
        Returns:
        the value associated with key or null if not found
      • reload

        public V reload​(K key,
                        V oldValue)
        Description copied from interface: CacheLoader
        Computes or retrieves a replacement value corresponding to an already-cached key. If the replacement value is not found then the mapping will be removed if null is returned. This method is called when an existing cache entry is refreshed by Caffeine.refreshAfterWrite(java.time.Duration), or through a call to LoadingCache.refresh(K).

        Note: all exceptions thrown by this method will be logged and then swallowed.

        Specified by:
        reload in interface CacheLoader<K,​V>
        Parameters:
        key - the non-null key whose value should be loaded
        oldValue - the non-null old value corresponding to key
        Returns:
        the new value associated with key, or null if 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: CacheLoader
        Asynchronously computes or retrieves a replacement value corresponding to an already-cached key. If the replacement value is not found then the mapping will be removed if null is computed. This method is called when an existing cache entry is refreshed by Caffeine.refreshAfterWrite(java.time.Duration), or through a call to LoadingCache.refresh(K).

        Note: all exceptions thrown by this method will be logged and then swallowed.

        Specified by:
        asyncReload in interface AsyncCacheLoader<K,​V>
        Specified by:
        asyncReload in interface CacheLoader<K,​V>
        Parameters:
        key - the non-null key whose value should be loaded
        oldValue - the non-null old value corresponding to key
        executor - the executor with which the entry is asynchronously loaded
        Returns:
        a future containing the new value associated with key, or containing null if the mapping is to be removed