Package org.cache2k.io
Interface AsyncCacheLoader.Context<K,V>
-
- All Superinterfaces:
DataAware<K,V>
- Enclosing interface:
- AsyncCacheLoader<K,V>
public static interface AsyncCacheLoader.Context<K,V> extends DataAware<K,V>
Relevant context information for a single load request.Rationale: Instead of a rather long parameter list, we define an interface. This allows us later to add some information without breaking implementations of the
AsyncCacheLoader
. The context does not include the cache, since the loader should not depend on it and do any other operations on the cache while loading.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Cache<K,V>
getCache()
The cache originating the load request@Nullable CacheEntry<K,V>
getCurrentEntry()
Current entry in the cache.Executor
getExecutor()
The configured executor for async operations.K
getKey()
Cache key for the load request.Executor
getLoaderExecutor()
The configured loader executor.long
getStartTime()
Start of load operationboolean
isRefreshAhead()
Operation is refresh and not an immediate client request.
-
-
-
Method Detail
-
getStartTime
long getStartTime()
Start of load operation- Returns:
- Time in millis since epoch or as defined by
TimeReference
.
-
getKey
K getKey()
Cache key for the load request. Although the key is a call parameter it is repeated here, so users can choose to pass on the key or the whole context.
-
getExecutor
Executor getExecutor()
The configured executor for async operations.- See Also:
Cache2kBuilder.executor(Executor)
-
getLoaderExecutor
Executor getLoaderExecutor()
The configured loader executor.- See Also:
Cache2kBuilder.loaderExecutor(Executor)
-
getCurrentEntry
@Nullable @Nullable CacheEntry<K,V> getCurrentEntry()
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:
- the current entry if a mapping is present in the cache, or
null
-
isRefreshAhead
boolean isRefreshAhead()
Operation is refresh and not an immediate client request. This can be used to execute the operation at a lower priority. TheCoalescingBulkLoader
is using the flag to delay refresh requests and combine them into bulk requests.
-
-