javax.cache
Interface CacheLoader<K,V>

Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values

public interface CacheLoader<K,V>

Used for read-through caching and loading data into a cache.

See CacheWriter which is used for write-through caching.

Since:
1.0
Author:
Greg Luck, Yannis Cosmadopoulos

Method Summary
 boolean canLoad(Object key)
          Checks whether an object for the key can be loaded.
 Cache.Entry<K,V> load(Object key)
          Loads an object.
 Map<K,V> loadAll(Collection<? extends K> keys)
          Loads multiple objects.
 

Method Detail

load

Cache.Entry<K,V> load(Object 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(Collection<? 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.

canLoad

boolean canLoad(Object key)
Checks whether an object for the key can be loaded. May be used by an implementation when the actual value is not needed (e.g. Cache.replace(Object, Object).

Parameters:
key - the key to check
Returns:
true if the key can be used to load a value


Copyright © 2011. All Rights Reserved.