类 EhCache
java.lang.Object
net.oschina.j2cache.ehcache.EhCache
- 所有已实现的接口:
Cloneable,Cache,Level1Cache,net.sf.ehcache.event.CacheEventListener
EHCache 2.x 的缓存封装
该封装类实现了缓存操作以及对缓存数据失效的侦听
- 作者:
- Winter Lau(javayou@gmail.com)
-
构造器概要
构造器构造器说明EhCache(net.sf.ehcache.Cache cache, CacheExpiredListener listener) Creates a new EhCache instance -
方法概要
修饰符和类型方法说明voidclear()Remove all elements in the cache, but leave the cache in a useable state.clone()voiddispose()voidRemoves the element which matches the key If no element matches, nothing is removed and no Exception is thrown.boolean判断缓存是否存在Gets a value of an element which matches the given key.get(Collection<String> keys) 批量获取缓存对象keys()Return all keysvoidnotifyElementEvicted(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem) voidnotifyElementExpired(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem) voidnotifyElementPut(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem) voidnotifyElementRemoved(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem) voidnotifyElementUpdated(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem) voidnotifyRemoveAll(net.sf.ehcache.Ehcache cache) voidPuts an object into the cache.void批量插入数据longsize()返回该缓存区域中,内存存储对象的最大数量longttl()返回该缓存区域的 TTL 设置(单位:秒)
-
构造器详细资料
-
EhCache
Creates a new EhCache instance- 参数:
cache- The underlying EhCache instance to use.listener- cache listener
-
-
方法详细资料
-
ttl
public long ttl()从接口复制的说明:Level1Cache返回该缓存区域的 TTL 设置(单位:秒)- 指定者:
ttl在接口中Level1Cache- 返回:
- true if cache support ttl setting
-
size
public long size()从接口复制的说明:Level1Cache返回该缓存区域中,内存存储对象的最大数量- 指定者:
size在接口中Level1Cache- 返回:
- cache size in memory
-
keys
从接口复制的说明:CacheReturn all keys -
get
Gets a value of an element which matches the given key. -
put
Puts an object into the cache. -
evict
Removes the element which matches the key If no element matches, nothing is removed and no Exception is thrown. -
get
从接口复制的说明:Cache批量获取缓存对象 -
exists
从接口复制的说明:Cache判断缓存是否存在 -
put
从接口复制的说明:Cache批量插入数据 -
clear
public void clear()Remove all elements in the cache, but leave the cache in a useable state. -
clone
- 指定者:
clone在接口中net.sf.ehcache.event.CacheEventListener- 覆盖:
clone在类中Object- 抛出:
CloneNotSupportedException
-
notifyElementExpired
public void notifyElementExpired(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem) - 指定者:
notifyElementExpired在接口中net.sf.ehcache.event.CacheEventListener
-
notifyElementEvicted
public void notifyElementEvicted(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem) - 指定者:
notifyElementEvicted在接口中net.sf.ehcache.event.CacheEventListener
-
notifyElementPut
public void notifyElementPut(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem) - 指定者:
notifyElementPut在接口中net.sf.ehcache.event.CacheEventListener
-
notifyElementRemoved
public void notifyElementRemoved(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem) - 指定者:
notifyElementRemoved在接口中net.sf.ehcache.event.CacheEventListener
-
notifyElementUpdated
public void notifyElementUpdated(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element elem) - 指定者:
notifyElementUpdated在接口中net.sf.ehcache.event.CacheEventListener
-
notifyRemoveAll
public void notifyRemoveAll(net.sf.ehcache.Ehcache cache) - 指定者:
notifyRemoveAll在接口中net.sf.ehcache.event.CacheEventListener
-
dispose
public void dispose()- 指定者:
dispose在接口中net.sf.ehcache.event.CacheEventListener
-