public class EhCacheWrapper extends Object implements ICache, ICacheLocker
DEFAULT, MULTILEVEL, REDIS| Constructor and Description |
|---|
EhCacheWrapper(ICaches owner,
Ehcache ehcache,
ICacheEventListener listener) |
| Modifier and Type | Method and Description |
|---|---|
ICacheLocker |
acquireCacheLocker()
获取缓存锁对象,若缓存实例不支持则返回null
|
void |
clear()
清理缓存
|
void |
close() |
Object |
get(Object key)
从缓存中获取对象
|
List<?> |
keys()
获取当前所有缓存对象key的集合
|
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(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 EhCacheWrapper(ICaches owner, Ehcache ehcache, ICacheEventListener listener)
public Object get(Object key) throws CacheException
ICacheget in interface ICachekey - 缓存keyCacheException - 可能产生的异常public void put(Object key, Object value) throws CacheException
ICacheput in interface ICachekey - 缓存keyvalue - 预缓存的元素对象CacheException - 可能产生的异常public void put(Object key, Object value, int timeout) throws CacheException
ICacheput in interface ICachekey - 缓存keyvalue - 预缓存的元素对象timeout - 自定义超时时间(秒),若为0则使用默认值CacheException - 可能产生的异常public void update(Object key, Object value) throws CacheException
ICacheupdate in interface ICachekey - 缓存keyvalue - 预缓存的元素对象CacheException - 可能产生的异常public void update(Object key, Object value, int timeout) throws CacheException
ICacheupdate in interface ICachekey - 缓存keyvalue - 预缓存的元素对象timeout - 自定义超时时间(秒),若为0则使用默认值CacheException - 可能产生的异常public List<?> keys() throws CacheException
ICachekeys in interface ICacheCacheException - 可能产生的异常public void remove(Object key) throws CacheException
ICacheremove in interface ICachekey - 缓存keyCacheException - 可能产生的异常public void removeAll(Collection<?> keys) throws CacheException
ICacheremoveAll in interface ICachekeys - 缓存key集合CacheException - 可能产生的异常public void clear()
throws CacheException
ICacheclear in interface ICacheCacheException - 可能产生的异常public void close()
throws Exception
close in interface AutoCloseableExceptionpublic ICacheLocker acquireCacheLocker()
ICacheacquireCacheLocker in interface ICachepublic void readLock(Object key)
ICacheLockerreadLock in interface ICacheLockerkey - 缓存锁Key值public void writeLock(Object key)
ICacheLockerwriteLock in interface ICacheLockerkey - 缓存锁Key值public boolean tryReadLock(Object key, long timeout) throws CacheException
ICacheLockertryReadLock in interface ICacheLockerkey - 缓存锁Key值timeout - 超时时间(毫秒)CacheException - 可能产生缓存异常public boolean tryWriteLock(Object key, long timeout) throws CacheException
ICacheLockertryWriteLock in interface ICacheLockerkey - 缓存锁Key值timeout - 超时时间(毫秒)CacheException - 可能产生缓存异常public void releaseReadLock(Object key)
ICacheLockerreleaseReadLock in interface ICacheLockerkey - 缓存锁Key值public void releaseWriteLock(Object key)
ICacheLockerreleaseWriteLock in interface ICacheLockerkey - 缓存锁Key值Copyright © 2022. All rights reserved.