Class JCacheLoaderAdapter<K,V>
- All Implemented Interfaces:
AsyncCacheLoader<K,
,Expirable<V>> CacheLoader<K,
Expirable<V>>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CacheProxy
<K, V> private final EventDispatcher
<K, V> private final javax.cache.expiry.ExpiryPolicy
private final JCacheStatisticsMXBean
private final Ticker
-
Constructor Summary
ConstructorsConstructorDescriptionJCacheLoaderAdapter
(javax.cache.integration.CacheLoader<K, V> delegate, EventDispatcher<K, V> dispatcher, javax.cache.expiry.ExpiryPolicy expiry, Ticker ticker, JCacheStatisticsMXBean statistics) -
Method Summary
Modifier and TypeMethodDescriptionprivate long
Computes or retrieves the value corresponding tokey
.Computes or retrieves the values corresponding tokeys
.void
setCache
(CacheProxy<K, V> cache) Sets the cache instance that was created with this loader.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.github.benmanes.caffeine.cache.CacheLoader
asyncLoad, asyncLoadAll, asyncReload, reload
-
Field Details
-
statistics
-
dispatcher
-
delegate
-
expiry
private final javax.cache.expiry.ExpiryPolicy expiry -
ticker
-
cache
-
-
Constructor Details
-
JCacheLoaderAdapter
public JCacheLoaderAdapter(javax.cache.integration.CacheLoader<K, V> delegate, EventDispatcher<K, V> dispatcher, javax.cache.expiry.ExpiryPolicy expiry, Ticker ticker, JCacheStatisticsMXBean statistics)
-
-
Method Details
-
setCache
Sets the cache instance that was created with this loader.- Parameters:
cache
- the cache that uses this loader
-
load
Description copied from interface:CacheLoader
Computes or retrieves the value corresponding tokey
.Warning: loading must not attempt to update any mappings of this cache directly.
- Specified by:
load
in interfaceCacheLoader<K,
V> - Parameters:
key
- the non-null key whose value should be loaded- Returns:
- the value associated with
key
ornull
if not found
-
loadAll
Description copied from interface:CacheLoader
Computes or retrieves the values corresponding tokeys
. This method is called byLoadingCache.getAll(java.lang.Iterable<? extends K>)
.If the returned map doesn't contain all requested
keys
then the entries it does contain will be cached andgetAll
will return the partial results. If the returned map contains extra keys not present inkeys
then all returned entries will be cached, but only the entries forkeys
will be returned fromgetAll
.This method should be overridden when bulk retrieval is significantly more efficient than many individual lookups. Note that
LoadingCache.getAll(java.lang.Iterable<? extends K>)
will defer to individual calls toLoadingCache.get(K)
if this method is not overridden.Warning: loading must not attempt to update any mappings of this cache directly.
- Specified by:
loadAll
in interfaceCacheLoader<K,
V> - Parameters:
keys
- the unique, non-null keys whose values should be loaded- Returns:
- a map from each key in
keys
to the value associated with that key; may not contain null values
-
expireTimeMS
private long expireTimeMS()
-