Package 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 for read-through caching and loading data into a cache.

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

    Since:
    1.0
    Author:
    Greg Luck, Yannis Cosmadopoulos
    • 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.