Package org.cache2k.io
Interface AdvancedCacheLoader<K,V>
-
- All Superinterfaces:
Customization
,DataAware<K,V>
,DataAwareCustomization<K,V>
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 theIf-Modified-Since
header.For general documentation on the loader, please see
CacheLoader
.- Since:
- 2
- Author:
- Jens Wilke
- See Also:
CacheLoader
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description V
load(K key, long startTime, @Nullable CacheEntry<K,V> currentEntry)
Retrieves or generates data based on the key parameter.
-
-
-
Method Detail
-
load
V load(K key, long startTime, @Nullable @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 reload or refresh. If expired before,null
is returned. IfCache2kBuilder.keepDataAfterExpired(boolean)
is enabled, also an expired entry is provided to the loader for optimization purposes. See also the description ofCache2kBuilder.keepDataAfterExpired(boolean)
andCache2kBuilder.refreshAhead(boolean)
.- Returns:
- value to be associated with the key. If the cache permits
null
values anull
is associated with the key. - Throws:
Exception
- Unhandled exception from the loader. Exceptions are suppressed or wrapped and rethrown via aCacheLoaderException
-
-