public class RefreshCache<K,V> extends LoadingCache<K,V>
| Constructor and Description |
|---|
RefreshCache(Cache cache) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Clean resources created by this cache.
|
V |
computeIfAbsent(K key,
Function<K,V> loader)
If there is a value associated with the key, return the value;
otherwise use the loader load the value and return, and then update the cache.
|
V |
computeIfAbsent(K key,
Function<K,V> loader,
boolean cacheNullWhenLoaderReturnNull)
If there is a value associated with the key, return the value;
otherwise use the loader load the value and return, and then update the cache.
|
V |
computeIfAbsent(K key,
Function<K,V> loader,
boolean cacheNullWhenLoaderReturnNull,
long expireAfterWrite,
TimeUnit timeUnit)
If there is a value associated with the key, return the value;
otherwise use the loader load the value and return, and then update the cache.
|
V |
get(K key)
Gets an entry from the cache.
|
Map<K,V> |
getAll(Set<? extends K> keys)
Gets a collection of entries from the Cache, returning them as Map of the values associated with
the set of keys requested.
|
config, GET_ALL, GET, getTargetCache, PUT_ALL, PUT_ALL, PUT_IF_ABSENT, put, PUT, put, PUT, putAll, putAll, putIfAbsent, REMOVE_ALL, remove, REMOVE, removeAll, tryLock, tryLockAndRun, unwrappublic RefreshCache(Cache cache)
public void close()
Cachepublic V computeIfAbsent(K key, Function<K,V> loader)
CachecomputeIfAbsent in interface Cache<K,V>computeIfAbsent in class SimpleProxyCache<K,V>key - the keyloader - the value loaderCacheConfig.isCacheNullValue()public V computeIfAbsent(K key, Function<K,V> loader, boolean cacheNullWhenLoaderReturnNull)
CachecomputeIfAbsent in interface Cache<K,V>computeIfAbsent in class SimpleProxyCache<K,V>key - the keyloader - the value loadercacheNullWhenLoaderReturnNull - true if null value returned by loader should put into cache use the keypublic V computeIfAbsent(K key, Function<K,V> loader, boolean cacheNullWhenLoaderReturnNull, long expireAfterWrite, TimeUnit timeUnit)
CachecomputeIfAbsent in interface Cache<K,V>computeIfAbsent in class SimpleProxyCache<K,V>key - the keyloader - the value loadercacheNullWhenLoaderReturnNull - true if null value returned by loader should put into cache use the keyexpireAfterWrite - the TTL(time to live) of the KV associationtimeUnit - the time unit of expireAfterWritepublic V get(K key) throws CacheInvokeException
CacheIf the cache's builder has specified a CacheLoader and there is no association in the cache
, it will attempt to load the entry.
If error occurs during cache access, the method return null instead of throwing an exception.
get in interface Cache<K,V>get in class LoadingCache<K,V>key - the key whose associated value is to be returnedCacheInvokeException - only if loader throws an exceptionCacheLoader,
Cache.GET(Object)public Map<K,V> getAll(Set<? extends K> keys) throws CacheInvokeException
CacheIf the cache's builder has specified a CacheLoader and there is no association in the cache
, it will attempt to load the entry.
If error occurs during cache access, the method will not throw an exception.
getAll in interface Cache<K,V>getAll in class LoadingCache<K,V>keys - The keys whose associated values are to be returned.CacheInvokeException - only if loader throws an exceptionCacheLoader,
Cache.GET_ALL(Set)Copyright © 2013–2022. All rights reserved.