Class CaffeinatedGuavaLoadingCache.SingleLoader<K,V>

java.lang.Object
com.github.benmanes.caffeine.guava.CaffeinatedGuavaLoadingCache.SingleLoader<K,V>
All Implemented Interfaces:
AsyncCacheLoader<K,V>, CacheLoader<K,V>, Serializable
Direct Known Subclasses:
CaffeinatedGuavaLoadingCache.BulkLoader
Enclosing class:
CaffeinatedGuavaLoadingCache<K,V>

static class CaffeinatedGuavaLoadingCache.SingleLoader<K,V> extends Object implements CacheLoader<K,V>, Serializable
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • cacheLoader

      final com.google.common.cache.CacheLoader<K,V> cacheLoader
  • Constructor Details

    • SingleLoader

      SingleLoader(com.google.common.cache.CacheLoader<K,V> cacheLoader)
  • Method Details

    • 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