public class RedisCacheWrapper extends Object implements ICache
DEFAULT, MULTILEVEL, REDIS
Constructor and Description |
---|
RedisCacheWrapper(ICaches owner,
IRedis redis,
String cacheName,
ICacheEventListener cacheEventListener) |
Modifier and Type | Method and Description |
---|---|
ICacheLocker |
acquireCacheLocker()
获取缓存锁对象,若缓存实例不支持则返回null
|
void |
clear()
清理缓存
|
void |
close() |
Object |
get(Object key)
从缓存中获取对象
|
List<String> |
keys()
获取当前所有缓存对象key的集合
|
void |
put(Object key,
Object value)
添加对象到缓存
|
void |
put(Object key,
Object value,
int timeout)
添加对象到缓存
|
void |
remove(Object key)
从缓存中移除对象
|
void |
removeAll(Collection<?> keys)
批量从缓存中移除对象
|
void |
update(Object key,
Object value)
更新对象到缓存
|
void |
update(Object key,
Object value,
int timeout)
更新对象到缓存
|
public RedisCacheWrapper(ICaches owner, IRedis redis, String cacheName, ICacheEventListener cacheEventListener)
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<String> keys() throws CacheException
ICache
keys
in interface ICache
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 clear() throws CacheException
ICache
clear
in interface ICache
CacheException
- 可能产生的异常public void close() throws Exception
close
in interface AutoCloseable
Exception
public ICacheLocker acquireCacheLocker()
ICache
acquireCacheLocker
in interface ICache
Copyright © 2022. All rights reserved.