类 SimpleProxyCache<K,V>
- 所有已实现的接口:
Cache<K,
,V> ProxyCache<K,
,V> Closeable
,AutoCloseable
- 直接已知子类:
LoadingCache
- 作者:
- huangli
-
字段概要
-
构造器概要
-
方法概要
修饰符和类型方法说明void
close()
Clean resources created by this cache.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.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.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.config()
Get the config of this cache.Gets an entry from the cache.Gets an entry from the cache.Gets a collection of entries from the Cache.Gets a collection of entries from the Cache, returning them as Map of the values associated with the set of keys requested.void
Associates the specified value with the specified key in the cache.void
Associates the specified value with the specified key in the cache.Associates the specified value with the specified key in the cache.Associates the specified value with the specified key in the cache.Copies all of the entries from the specified map to the cache.Copies all of the entries from the specified map to the cache.PUT_IF_ABSENT
(K key, V value, long expireAfterWrite, TimeUnit timeUnit) If the specified key is not already associated with a value, associate it with the given value.void
Copies all of the entries from the specified map to the cache.void
Copies all of the entries from the specified map to the cache.boolean
putIfAbsent
(K key, V value) Atomically associates the specified key with the given value if it is not already associated with a value.boolean
Removes the mapping for a key from this cache if it is present.Removes the mapping for a key from this cache if it is present.REMOVE_ALL
(Set<? extends K> keys) Removes entries for the specified keys.void
Removes entries for the specified keys.Use this cache attempt to acquire a exclusive lock specified by the key, this method will not block.boolean
tryLockAndRun
(K key, long expire, TimeUnit timeUnit, Runnable action) Use this cache to try run an action exclusively.<T> T
Provides a standard way to access the underlying concrete cache entry implementation in order to provide access to further, proprietary features.
-
构造器详细资料
-
SimpleProxyCache
-
-
方法详细资料
-
config
从接口复制的说明:Cache
Get the config of this cache. -
getTargetCache
- 指定者:
getTargetCache
在接口中ProxyCache<K,
V>
-
get
从接口复制的说明:Cache
Gets an entry from the cache.If 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.
-
getAll
从接口复制的说明:Cache
Gets a collection of entries from the Cache, returning them as Map of the values associated with the set of keys requested.If 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.
-
put
从接口复制的说明:Cache
Associates the specified value with the specified key in the cache.If error occurs during cache access, the method will not throw an exception.
if the implementation supports asynchronous operation, the cache operation of this method is asynchronous.
-
putAll
从接口复制的说明:Cache
Copies all of the entries from the specified map to the cache.If error occurs during cache access, the method will not throw an exception.
if the implementation supports asynchronous operation, the cache operation of this method is asynchronous.
-
putIfAbsent
从接口复制的说明:Cache
Atomically associates the specified key with the given value if it is not already associated with a value.If error occurs during cache access, the method will not throw an exception.
MultiLevelCache
does not support this method.- 指定者:
putIfAbsent
在接口中Cache<K,
V> - 参数:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key- 返回:
- true if a value was set, false if the KV association does not exists in the cache, or error occurs during cache access.
- 另请参阅:
-
remove
从接口复制的说明:Cache
Removes the mapping for a key from this cache if it is present.If error occurs during cache access, the method will not throw an exception.
-
removeAll
从接口复制的说明:Cache
Removes entries for the specified keys.If error occurs during cache access, the method will not throw an exception.
if the implementation supports asynchronous operation, the cache operation of this method is asynchronous.
-
unwrap
从接口复制的说明:Cache
Provides a standard way to access the underlying concrete cache entry implementation in order to provide access to further, proprietary features.If the implementation does not support the specified class, the
IllegalArgumentException
is thrown. -
tryLock
从接口复制的说明:Cache
Use this cache attempt to acquire a exclusive lock specified by the key, this method will not block. examples:try(AutoReleaseLock lock = cache.tryLock("MyKey",100, TimeUnit.SECONDS)){ if(lock != null){ // do something } }
MultiLevelCache
will use the last level cache to support this operation.- 指定者:
tryLock
在接口中Cache<K,
V> - 参数:
key
- lockKeyexpire
- lock expire timetimeUnit
- lock expire time unit- 返回:
- an AutoReleaseLock(implements java.lang.AutoCloseable) instance if success. or null if the attempt fails, which indicates there is an another thread/process/server has the lock, or error occurs during cache access.
- 另请参阅:
-
tryLockAndRun
从接口复制的说明:Cache
Use this cache to try run an action exclusively.
examples:MultiLevelCache
will use the last level cache to support this operation.cache.tryLock("MyKey",100, TimeUnit.SECONDS),() -> { //do something });
- 指定者:
tryLockAndRun
在接口中Cache<K,
V> - 参数:
key
- lockKeyexpire
- lock expire timetimeUnit
- lock expire time unitaction
- the action need to execute- 返回:
- true if successfully get the lock and the action is executed
-
GET
从接口复制的说明:Cache
Gets an entry from the cache.if the implementation supports asynchronous operation, the cache access may not completed after this method return. The invoke of getResultCode()/isSuccess()/getMessage()/getValue() on the result will block until cache operation is completed. Call future() method on the result will get a CompletionStage instance for asynchronous programming.
-
GET_ALL
从接口复制的说明:Cache
Gets a collection of entries from the Cache.if the implementation supports asynchronous operation, the cache access may not completed after this method return. The invoke of getResultCode()/isSuccess()/getMessage()/getValue() on the result will block until cache operation is completed. Call future() method on the result will get a CompletionStage instance for asynchronous programming.
-
computeIfAbsent
从接口复制的说明:Cache
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.- 指定者:
computeIfAbsent
在接口中Cache<K,
V> - 参数:
key
- the keyloader
- the value loader- 返回:
- the value
- 另请参阅:
-
computeIfAbsent
从接口复制的说明:Cache
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.- 指定者:
computeIfAbsent
在接口中Cache<K,
V> - 参数:
key
- the keyloader
- the value loadercacheNullWhenLoaderReturnNull
- true if null value returned by loader should put into cache use the key- 返回:
- the value
-
computeIfAbsent
public V computeIfAbsent(K key, Function<K, V> loader, boolean cacheNullWhenLoaderReturnNull, long expireAfterWrite, TimeUnit timeUnit) 从接口复制的说明:Cache
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.- 指定者:
computeIfAbsent
在接口中Cache<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 expireAfterWrite- 返回:
- the value
-
put
从接口复制的说明:Cache
Associates the specified value with the specified key in the cache.If error occurs during cache access, the method will not throw an exception.
-
PUT
从接口复制的说明:Cache
Associates the specified value with the specified key in the cache.if the implementation supports asynchronous operation, the cache access may not completed after this method return. The invoke of getResultCode()/isSuccess()/getMessage() on the result will block until cache operation is completed. Call future() method on the result will get a CompletionStage instance for asynchronous programming.
-
PUT
从接口复制的说明:Cache
Associates the specified value with the specified key in the cache.if the implementation supports asynchronous operation, the cache access may not completed after this method return. The invoke of getResultCode()/isSuccess()/getMessage() on the result will block until cache operation is completed. Call future() method on the result will get a CompletionStage instance for asynchronous programming.
-
putAll
从接口复制的说明:Cache
Copies all of the entries from the specified map to the cache.If error occurs during cache access, the method will not throw an exception.
-
PUT_ALL
从接口复制的说明:Cache
Copies all of the entries from the specified map to the cache.if the implementation supports asynchronous operation, the cache access may not completed after this method return. The invoke of getResultCode()/isSuccess()/getMessage() on the result will block until cache operation is completed. Call future() method on the result will get a CompletionStage instance for asynchronous programming.
-
PUT_ALL
public CacheResult PUT_ALL(Map<? extends K, ? extends V> map, long expireAfterWrite, TimeUnit timeUnit) 从接口复制的说明:Cache
Copies all of the entries from the specified map to the cache.if the implementation supports asynchronous operation, the cache access may not completed after this method return. The invoke of getResultCode()/isSuccess()/getMessage() on the result will block until cache operation is completed. Call future() method on the result will get a CompletionStage instance for asynchronous programming.
-
REMOVE
从接口复制的说明:Cache
Removes the mapping for a key from this cache if it is present.if the implementation supports asynchronous operation, the cache access may not completed after this method return. The invoke of getResultCode()/isSuccess()/getMessage() on the result will block until cache operation is completed. Call future() method on the result will get a CompletionStage instance for asynchronous programming.
-
REMOVE_ALL
从接口复制的说明:Cache
Removes entries for the specified keys.if the implementation supports asynchronous operation, the cache access may not completed after this method return. The invoke of getResultCode()/isSuccess()/getMessage() on the result will block until cache operation is completed. Call future() method on the result will get a CompletionStage instance for asynchronous programming.
- 指定者:
REMOVE_ALL
在接口中Cache<K,
V> - 参数:
keys
- the keys to remove- 返回:
- the result
-
PUT_IF_ABSENT
从接口复制的说明:Cache
If the specified key is not already associated with a value, associate it with the given value.if the implementation supports asynchronous operation, the cache access may not completed after this method return. The invoke of getResultCode()/isSuccess()/getMessage() on the result will block until cache operation is completed. Call future() method on the result will get a CompletionStage instance for asynchronous programming.
- 指定者:
PUT_IF_ABSENT
在接口中Cache<K,
V> - 参数:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyexpireAfterWrite
- the TTL(time to live) of the KV associationtimeUnit
- the time unit of expireAfterWrite- 返回:
- SUCCESS if the specified key is not already associated with a value, or EXISTS if the specified key is already associated with a value, or FAIL if error occurs.
-
close
public void close()从接口复制的说明:Cache
Clean resources created by this cache.
-