public class MultiLevelCache<K,V> extends AbstractCache<K,V>
| 构造器和说明 |
|---|
MultiLevelCache(Cache... caches)
已过时。
|
MultiLevelCache(MultiLevelCacheConfig<K,V> cacheConfig) |
| 限定符和类型 | 方法和说明 |
|---|---|
Cache[] |
caches() |
void |
close()
Clean resources created by this cache.
|
MultiLevelCacheConfig<K,V> |
config()
Get the config of this cache.
|
CacheResult |
PUT_ALL(Map<? extends K,? extends V> map)
Copies all of the entries from the specified map to the cache.
|
CacheResult |
PUT(K key,
V value)
Associates the specified value with the specified key in 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.
|
AutoReleaseLock |
tryLock(K key,
long expire,
TimeUnit timeUnit)
Use this cache attempt to acquire a exclusive lock specified by the key, this method will not block.
|
<T> T |
unwrap(Class<T> clazz)
Provides a standard way to access the underlying concrete cache entry
implementation in order to provide access to further, proprietary features.
|
computeIfAbsent, computeIfAbsent, GET_ALL, GET, notify, PUT_ALL, PUT_IF_ABSENT, PUT, REMOVE_ALL, REMOVE@Deprecated public MultiLevelCache(Cache... caches) throws CacheConfigException
public MultiLevelCache(MultiLevelCacheConfig<K,V> cacheConfig) throws CacheConfigException
public Cache[] caches()
public MultiLevelCacheConfig<K,V> config()
Cachepublic CacheResult PUT(K key, V value)
Cacheif 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.
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic CacheResult PUT_ALL(Map<? extends K,? extends V> map)
Cacheif 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.
map - mappings to be stored in this cache.public <T> T unwrap(Class<T> clazz)
Cache
If the implementation does not support the specified class,
the IllegalArgumentException is thrown.
clazz - the proprietary class or interface of the underlying
concrete cache. It is this type that is returned.public AutoReleaseLock tryLock(K key, long expire, TimeUnit timeUnit)
Cache
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.
key - lockKeyexpire - lock expire timetimeUnit - lock expire time unitCache.tryLockAndRun(Object, long, TimeUnit, Runnable)public boolean putIfAbsent(K key, V value)
CacheIf error occurs during cache access, the method will not throw an exception.
MultiLevelCache does not support this method.
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyCache.PUT_IF_ABSENT(Object, Object, long, TimeUnit)public void close()
CacheCopyright © 2013–2019. All rights reserved.