类 SimpleProxyCache<K,V>
- 所有已实现的接口:
Cache<K,,V> ProxyCache<K,,V> Closeable,AutoCloseable
- 直接已知子类:
LoadingCache
- 作者:
- huangli
-
字段概要
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidclose()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.voidAssociates the specified value with the specified key in the cache.voidAssociates 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.voidCopies all of the entries from the specified map to the cache.voidCopies all of the entries from the specified map to the cache.booleanputIfAbsent(K key, V value) Atomically associates the specified key with the given value if it is not already associated with a value.booleanRemoves 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.voidRemoves entries for the specified keys.Use this cache attempt to acquire a exclusive lock specified by the key, this method will not block.booleantryLockAndRun(K key, long expire, TimeUnit timeUnit, Runnable action) Use this cache to try run an action exclusively.<T> TProvides a standard way to access the underlying concrete cache entry implementation in order to provide access to further, proprietary features.
-
构造器详细资料
-
SimpleProxyCache
-
-
方法详细资料
-
config
从接口复制的说明:CacheGet the config of this cache. -
getTargetCache
- 指定者:
getTargetCache在接口中ProxyCache<K,V>
-
get
从接口复制的说明:CacheGets an entry from the cache.If the cache's builder has specified a
CacheLoaderand 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
从接口复制的说明:CacheGets 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
CacheLoaderand 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
从接口复制的说明:CacheAssociates 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
从接口复制的说明:CacheCopies 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
从接口复制的说明:CacheAtomically 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.
MultiLevelCachedoes 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
从接口复制的说明:CacheRemoves 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
从接口复制的说明:CacheRemoves 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
从接口复制的说明:CacheProvides 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
IllegalArgumentExceptionis thrown. -
tryLock
从接口复制的说明:CacheUse 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 } }MultiLevelCachewill 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
从接口复制的说明:CacheUse this cache to try run an action exclusively.
examples:MultiLevelCachewill 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
从接口复制的说明:CacheGets 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
从接口复制的说明:CacheGets 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
从接口复制的说明:CacheIf 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
从接口复制的说明:CacheIf 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) 从接口复制的说明:CacheIf 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
从接口复制的说明:CacheAssociates the specified value with the specified key in the cache.If error occurs during cache access, the method will not throw an exception.
-
PUT
从接口复制的说明:CacheAssociates 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
从接口复制的说明:CacheAssociates 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
从接口复制的说明:CacheCopies 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
从接口复制的说明:CacheCopies 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) 从接口复制的说明:CacheCopies 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
从接口复制的说明:CacheRemoves 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
从接口复制的说明:CacheRemoves 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
从接口复制的说明:CacheIf 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()从接口复制的说明:CacheClean resources created by this cache.
-