Interface CacheLoader<K,V>
- Type Parameters:
K- key type (must be non-null)V- value type (must be non-null)
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface for loading values in cache-aside pattern.
Implementations should load a value from an upstream source (database, API, etc.) when the cache experiences a miss. Loaders are responsible for returning non-null values.
Thread Safety
Implementations must be thread-safe as they may be called from multiple threads concurrently.-
Method Summary
-
Method Details
-
load
Load a value for the given key.- Parameters:
key- the key to load (must not be null)- Returns:
- the loaded value (must not be null)
- Throws:
NullPointerException- if key is nullException- if loading fails
-