01: package javax.cache.spi;
02:
03: import java.util.Collection;
04: import java.util.Map;
05:
06: /**
07: * A CacheLoader is used by a cache to request missing data on a cache miss,
08: * or to pre-load specific data into the cache. The CacheLoader is considered
09: * to be part of the application, and not part of the cache implementation
10: * itself, and as such is considered a form of call-back interface.
11: *
12: * @author cp 2003.05.29
13: */
14: public interface CacheLoader<K, V> {
15: /**
16: * Return the value associated with the specified key, or null if the
17: * key does not have an associated value in the underlying store.
18: *
19: * @param oKey key whose associated value is to be returned
20: * @return the value associated with the specified key, or
21: * <tt>null</tt> if no value is available for that key
22: * @throws CacheLoaderException the CacheLoader wrap an exception that
23: * occurs when loading data, such as an exception from the data
24: * source, as a CacheLoaderException to report the failure back
25: * to the calling cache
26: */
27: public V load(K oKey) throws CacheLoaderException;
28:
29: /**
30: * Return the values associated with each the specified keys in the
31: * passed collection. If a key does not have an associated value in
32: * the underlying store, then the return map will not have an entry
33: * for that key.
34: *
35: * @param colKeys a collection of keys to load
36: * @return a Map of keys to associated values for the specified keys
37: * @throws CacheLoaderException the CacheLoader wrap an exception that
38: * occurs when loading data, such as an exception from the data
39: * source, as a CacheLoaderException to report the failure back
40: * to the calling cache
41: */
42: public Map<K, V> loadAll(Collection<? extends K> colKeys)
43: throws CacheLoaderException;
44:
45: public void censorPut(K key, V value) throws CacheLoaderException;
46:
47: }
|