javax.cache.integration.CacheLoader Maven / Gradle / Ivy
/**
* Copyright (c) 2011-2013 Terracotta, Inc.
* Copyright (c) 2011-2013 Oracle and/or its affiliates.
*
* All rights reserved. Use is subject to license terms.
*/
package javax.cache.integration;
import javax.cache.configuration.CompleteConfiguration;
import java.util.Map;
/**
* Used when a cache is read-through or when loading data into a cache via the
* {@link javax.cache.Cache#loadAll(java.util.Set, boolean,
* CompletionListener)} method.
*
* @param the type of keys handled by this loader
* @param the type of values generated by this loader
* @author Greg Luck
* @author Yannis Cosmadopoulos
* @see CompleteConfiguration#isReadThrough()
* @see CacheWriter
* @since 1.0
*/
public interface CacheLoader {
/**
* 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 loaded null
should be returned.
*
* @param key the key identifying the object being loaded
* @return 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.
*/
V load(K key) 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.
*
* @param keys keys identifying the values to be loaded
* @return A map of key, values to be stored in the cache.
* @throws CacheLoaderException if there is problem executing the loader.
*/
Map loadAll(Iterable extends K> keys) throws CacheLoaderException;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy