javax.cache
Interface CacheLoader<K,V>

Type Parameters:
K - the type of keys handled by this loader
V - 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 the Cache.load(Object) and Cache.loadAll(java.util.Set) methods.

See CacheWriter which is the corollary for load used for write-through caching.

Since:
1.0
Author:
Greg Luck, Yannis Cosmadopoulos

Method Summary
 Cache.Entry<K,V> load(K key)
          Loads an object.
 Map<K,V> loadAll(Iterable<? extends K> keys)
          Loads multiple objects.
 

Method Detail

load

Cache.Entry<K,V> load(K key)
Loads an object. Application writers should implement this method to customize the loading of cache object. This method is called by the caching service when the requested object is not in the cache.

Parameters:
key - the key identifying the object being loaded
Returns:
The entry for the object that is to be stored in the cache.

loadAll

Map<K,V> loadAll(Iterable<? extends K> keys)
Loads multiple objects. Application writers should implement this method to customize the loading of cache object. This method is called by the caching service when the requested object is not in the cache.

Parameters:
keys - keys identifying the values to be loaded
Returns:
A Map of objects that are to be stored in the cache.


Copyright © 2013. All Rights Reserved.