Class CacheLoader<K,​V>

    • Constructor Detail

      • CacheLoader

        public CacheLoader()
        Deprecated.
    • Method Detail

      • load

        public abstract V load​(K key)
                        throws Exception
        Deprecated.
        Retrieves or generates data based on the key.

        From inside this method it is illegal to call methods on the same cache. This may cause a deadlock.

        API rationale: This method declares an exception to allow any unhandled exceptions of the loader implementation to just pass through. Since the cache needs to catch an deal with loader exceptions in any way, this saves otherwise necessary try/catch clauses in the loader.

        Specified by:
        load in interface CacheLoader<K,​V>
        Specified by:
        load in interface FunctionalCacheLoader<K,​V>
        Parameters:
        key - the non-null key to provide the value for.
        Returns:
        value to be associated with the key. If the cache does not permit null values a NullPointerException is thrown, but the expiry policy is called before it.
        Throws:
        Exception - Unhandled exception from the loader. Exceptions are suppressed or wrapped and rethrown via a CacheLoaderException
        See Also:
        load(Object)
      • loadAll

        public Map<K,​V> loadAll​(Iterable<? extends K> keys,
                                      Executor executor)
                               throws Exception
        Deprecated.
        Loads multiple values to the cache.

        From inside this method it is illegal to call methods on the same cache. This may cause a deadlock.

        The method is provided to complete the API. At the moment cache2k is not using it. Please see the road map.

        Parameters:
        keys - set of keys for the values to be loaded
        executor - an executor for concurrent loading
        Returns:
        The loaded values. A key may map to null if the cache permits null values.
        Throws:
        Exception - Unhandled exception from the loader. Exceptions are suppressed or wrapped and rethrown via a CacheLoaderException. If an exception happens the cache may retry the load with the single value load method.