public class MultilevelCacheWrapper extends Object implements ICache, ICacheLocker
DEFAULT, MULTILEVEL, REDIS
Constructor and Description |
---|
MultilevelCacheWrapper(ICaches owner,
String cacheName,
ICache masterCache,
IRedis redis) |
Modifier and Type | Method and Description |
---|---|
ICacheLocker |
acquireCacheLocker()
获取缓存锁对象,若缓存实例不支持则返回null
|
void |
clear()
清理缓存
|
void |
clear(boolean master) |
void |
close() |
Object |
get(Object key)
从缓存中获取对象
|
List<?> |
keys()
获取当前所有缓存对象key的集合
|
List<?> |
keys(boolean master) |
void |
put(Object key,
Object value)
添加对象到缓存
|
void |
put(Object key,
Object value,
int timeout)
添加对象到缓存
|
void |
readLock(Object key)
设置读锁
|
void |
releaseReadLock(Object key)
释放读锁
|
void |
releaseWriteLock(Object key)
释放写锁
|
void |
remove(Object key)
从缓存中移除对象
|
void |
removeAll(boolean master,
Collection<?> keys) |
void |
removeAll(Collection<?> keys)
批量从缓存中移除对象
|
boolean |
tryReadLock(Object key,
long timeout)
尝试设置读锁,等待timeout毫秒时间
|
boolean |
tryWriteLock(Object key,
long timeout)
尝试设置写锁,等待timeout毫秒时间
|
void |
update(Object key,
Object value)
更新对象到缓存
|
void |
update(Object key,
Object value,
int timeout)
更新对象到缓存
|
void |
writeLock(Object key)
设置写锁
|
public Object get(Object key) throws CacheException
ICache
get
in interface ICache
key
- 缓存keyCacheException
- 可能产生的异常public void put(Object key, Object value) throws CacheException
ICache
put
in interface ICache
key
- 缓存keyvalue
- 预缓存的元素对象CacheException
- 可能产生的异常public void put(Object key, Object value, int timeout) throws CacheException
ICache
put
in interface ICache
key
- 缓存keyvalue
- 预缓存的元素对象timeout
- 自定义超时时间(秒),若为0则使用默认值CacheException
- 可能产生的异常public void update(Object key, Object value) throws CacheException
ICache
update
in interface ICache
key
- 缓存keyvalue
- 预缓存的元素对象CacheException
- 可能产生的异常public void update(Object key, Object value, int timeout) throws CacheException
ICache
update
in interface ICache
key
- 缓存keyvalue
- 预缓存的元素对象timeout
- 自定义超时时间(秒),若为0则使用默认值CacheException
- 可能产生的异常public List<?> keys() throws CacheException
ICache
keys
in interface ICache
CacheException
- 可能产生的异常public List<?> keys(boolean master) throws CacheException
CacheException
public void remove(Object key) throws CacheException
ICache
remove
in interface ICache
key
- 缓存keyCacheException
- 可能产生的异常public void removeAll(Collection<?> keys) throws CacheException
ICache
removeAll
in interface ICache
keys
- 缓存key集合CacheException
- 可能产生的异常public void removeAll(boolean master, Collection<?> keys) throws CacheException
CacheException
public void clear() throws CacheException
ICache
clear
in interface ICache
CacheException
- 可能产生的异常public void clear(boolean master) throws CacheException
CacheException
public void close() throws Exception
close
in interface AutoCloseable
Exception
public ICacheLocker acquireCacheLocker()
ICache
acquireCacheLocker
in interface ICache
public void readLock(Object key)
ICacheLocker
readLock
in interface ICacheLocker
key
- 缓存锁Key值public void writeLock(Object key)
ICacheLocker
writeLock
in interface ICacheLocker
key
- 缓存锁Key值public boolean tryReadLock(Object key, long timeout) throws CacheException
ICacheLocker
tryReadLock
in interface ICacheLocker
key
- 缓存锁Key值timeout
- 超时时间(毫秒)CacheException
- 可能产生缓存异常public boolean tryWriteLock(Object key, long timeout) throws CacheException
ICacheLocker
tryWriteLock
in interface ICacheLocker
key
- 缓存锁Key值timeout
- 超时时间(毫秒)CacheException
- 可能产生缓存异常public void releaseReadLock(Object key)
ICacheLocker
releaseReadLock
in interface ICacheLocker
key
- 缓存锁Key值public void releaseWriteLock(Object key)
ICacheLocker
releaseWriteLock
in interface ICacheLocker
key
- 缓存锁Key值Copyright © 2022. All rights reserved.