public class EhCache extends Object implements Level1Cache, net.sf.ehcache.event.CacheEventListener
EHCache 2.x 的缓存封装
该封装类实现了缓存操作以及对缓存数据失效的侦听
| 构造器和说明 |
|---|
EhCache(net.sf.ehcache.Cache cache,
CacheExpiredListener listener)
Creates a new EhCache instance
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
clear()
Remove all elements in the cache, but leave the cache
in a useable state.
|
Object |
clone() |
void |
dispose() |
void |
evict(String... keys)
Removes the element which matches the key
If no element matches, nothing is removed and no Exception is thrown.
|
boolean |
exists(String key)
判断缓存是否存在
|
Map<String,Object> |
get(Collection<String> keys)
批量获取缓存对象
|
Serializable |
get(String key)
Gets a value of an element which matches the given key.
|
Collection<String> |
keys()
Return all keys
|
void |
notifyElementEvicted(net.sf.ehcache.Ehcache cache,
net.sf.ehcache.Element elem) |
void |
notifyElementExpired(net.sf.ehcache.Ehcache cache,
net.sf.ehcache.Element elem) |
void |
notifyElementPut(net.sf.ehcache.Ehcache cache,
net.sf.ehcache.Element elem) |
void |
notifyElementRemoved(net.sf.ehcache.Ehcache cache,
net.sf.ehcache.Element elem) |
void |
notifyElementUpdated(net.sf.ehcache.Ehcache cache,
net.sf.ehcache.Element elem) |
void |
notifyRemoveAll(net.sf.ehcache.Ehcache cache) |
void |
put(Map<String,Object> elements)
批量插入数据
|
void |
put(String key,
Object value)
Puts an object into the cache.
|
long |
size()
返回该缓存区域中,内存存储对象的最大数量
|
long |
ttl()
返回该缓存区域的 TTL 设置(单位:秒)
|
public EhCache(net.sf.ehcache.Cache cache,
CacheExpiredListener listener)
cache - The underlying EhCache instance to use.listener - cache listenerpublic long ttl()
Level1Cachettl 在接口中 Level1Cachepublic long size()
Level1Cachesize 在接口中 Level1Cachepublic Collection<String> keys()
Cachepublic Serializable get(String key)
public void evict(String... keys)
public void clear()
public Object clone() throws CloneNotSupportedException
clone 在接口中 net.sf.ehcache.event.CacheEventListenerclone 在类中 ObjectCloneNotSupportedExceptionpublic void notifyElementExpired(net.sf.ehcache.Ehcache cache,
net.sf.ehcache.Element elem)
notifyElementExpired 在接口中 net.sf.ehcache.event.CacheEventListenerpublic void notifyElementEvicted(net.sf.ehcache.Ehcache cache,
net.sf.ehcache.Element elem)
notifyElementEvicted 在接口中 net.sf.ehcache.event.CacheEventListenerpublic void notifyElementPut(net.sf.ehcache.Ehcache cache,
net.sf.ehcache.Element elem)
notifyElementPut 在接口中 net.sf.ehcache.event.CacheEventListenerpublic void notifyElementRemoved(net.sf.ehcache.Ehcache cache,
net.sf.ehcache.Element elem)
notifyElementRemoved 在接口中 net.sf.ehcache.event.CacheEventListenerpublic void notifyElementUpdated(net.sf.ehcache.Ehcache cache,
net.sf.ehcache.Element elem)
notifyElementUpdated 在接口中 net.sf.ehcache.event.CacheEventListenerpublic void notifyRemoveAll(net.sf.ehcache.Ehcache cache)
notifyRemoveAll 在接口中 net.sf.ehcache.event.CacheEventListenerpublic void dispose()
dispose 在接口中 net.sf.ehcache.event.CacheEventListenerCopyright © 2018. All rights reserved.