Interface CacheLoader<K,V>

Type Parameters:
K - the type of key used by the cache
V - the type of value stored in the cache

@PublicSpi public interface CacheLoader<K,V>
Populates a cache, for example lazily upon a miss.
Since:
2.0
  • Method Summary

    Modifier and Type
    Method
    Description
    load(K key)
    Loads the value for the given key.
  • Method Details

    • load

      @Nonnull V load(@Nonnull K key)
      Loads the value for the given key.
      Parameters:
      key - the key for which to load the value (required)
      Returns:
      a non-null value; if null values are possible, e.g. when the key is a database ID that does not actually exist, declare the loader's value type to be a wrapper type such as Guava's Option<Foo> class