Interface AdvancedCacheLoader<K,​V>

  • All Superinterfaces:
    Customization, DataAware<K,​V>, DataAwareCustomization<K,​V>
    All Known Implementing Classes:
    AdvancedCacheLoader

    public interface AdvancedCacheLoader<K,​V>
    extends DataAwareCustomization<K,​V>
    Retrieves or generates a value to load into the cache. The advanced loader interface contains the current time and the previous cache entry. The previous cache entry can be used for a more intelligent loading strategy, e.g. for HTTP based loading with the If-Modified-Since header.

    For general documentation on the loader, please see CacheLoader.

    Since:
    2
    Author:
    Jens Wilke
    See Also:
    CacheLoader
    • Method Detail

      • load

        V load​(K key,
               long startTime,
               @Nullable CacheEntry<K,​V> currentEntry)
        throws Exception
        Retrieves or generates data based on the key parameter.
        Parameters:
        key - The non-null key to provide the value for.
        startTime - Time in millis, retrieved before the call.
        currentEntry - Current entry in the cache. The entry is available if the load is caused by a reload or refresh. If expired before, null is returned. If Cache2kBuilder.keepDataAfterExpired(boolean) is enabled, also an expired entry is provided to the loader for optimization purposes. See also the description of Cache2kBuilder.keepDataAfterExpired(boolean) and Cache2kBuilder.refreshAhead(boolean).
        Returns:
        value to be associated with the key. If the cache permits null values a null is associated with the key.
        Throws:
        Exception - Unhandled exception from the loader. Exceptions are suppressed or wrapped and rethrown via a CacheLoaderException