public class EhCache extends Object implements Level1Cache, net.sf.ehcache.event.CacheEventListener
EHCache 2.x 的缓存封装
该封装类实现了缓存操作以及对缓存数据失效的侦听
Constructor and Description |
---|
EhCache(net.sf.ehcache.Cache cache,
CacheExpiredListener listener)
Creates a new EhCache instance
|
Modifier and Type | Method and Description |
---|---|
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()
Level1Cache
ttl
in interface Level1Cache
public long size()
Level1Cache
size
in interface Level1Cache
public Collection<String> keys()
Cache
public Serializable get(String key)
public void evict(String... keys)
public Map<String,Object> get(Collection<String> keys)
Cache
public void clear()
public Object clone() throws CloneNotSupportedException
clone
in interface net.sf.ehcache.event.CacheEventListener
clone
in class Object
CloneNotSupportedException
public void notifyElementExpired(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem)
notifyElementExpired
in interface net.sf.ehcache.event.CacheEventListener
public void notifyElementEvicted(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem)
notifyElementEvicted
in interface net.sf.ehcache.event.CacheEventListener
public void notifyElementPut(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem)
notifyElementPut
in interface net.sf.ehcache.event.CacheEventListener
public void notifyElementRemoved(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem)
notifyElementRemoved
in interface net.sf.ehcache.event.CacheEventListener
public void notifyElementUpdated(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem)
notifyElementUpdated
in interface net.sf.ehcache.event.CacheEventListener
public void notifyRemoveAll(net.sf.ehcache.Ehcache cache)
notifyRemoveAll
in interface net.sf.ehcache.event.CacheEventListener
public void dispose()
dispose
in interface net.sf.ehcache.event.CacheEventListener
Copyright © 2018. All rights reserved.