Package javax.cache.integration
Interface CacheLoader<K,V>
-
- Type Parameters:
K
- the type of keys handled by this loaderV
- the type of values generated by this loader
public interface CacheLoader<K,V>
Used when a cache is read-through or when loading data into a cache via theCache.loadAll(java.util.Set, boolean, CompletionListener)
method.- Since:
- 1.0
- Author:
- Greg Luck, Yannis Cosmadopoulos
- See Also:
CompleteConfiguration.isReadThrough()
,CacheWriter
-
-
Method Detail
-
load
V load(K key) throws CacheLoaderException
Loads an object. Application developers should implement this method to customize the loading of a value for a cache entry. This method is called by a cache when a requested entry is not in the cache. If the object can't be loadednull
should be returned.- Parameters:
key
- the key identifying the object being loaded- Returns:
- The value for the entry that is to be stored in the cache or
null
if the object can't be loaded - Throws:
CacheLoaderException
- if there is problem executing the loader.
-
loadAll
Map<K,V> loadAll(Iterable<? extends K> keys) throws CacheLoaderException
Loads multiple objects. Application developers should implement this method to customize the loading of cache entries. This method is called when the requested object is not in the cache. If an object can't be loaded, it is not returned in the resulting map.- Parameters:
keys
- keys identifying the values to be loaded- Returns:
- A map of key, values to be stored in the cache.
- Throws:
CacheLoaderException
- if there is problem executing the loader.
-
-