public class EhCache3 extends Object implements Level1Cache, org.ehcache.event.CacheEventListener
EHCache 3.x 的缓存封装
该封装类实现了缓存操作以及对缓存数据失效的侦听
Constructor and Description |
---|
EhCache3(String name,
org.ehcache.Cache<String,Object> cache,
CacheExpiredListener listener) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the cache
|
void |
evict(String... keys)
Remove items from the cache
|
boolean |
exists(String key)
判断缓存是否存在
|
Map<String,Object> |
get(Collection<String> keys)
批量获取缓存对象
|
Object |
get(String key)
Get an item from the cache, nontransactionally
|
Collection<String> |
keys()
Return all keys
|
void |
onEvent(org.ehcache.event.CacheEvent cacheEvent) |
void |
put(Map<String,Object> elements)
批量插入数据
|
void |
put(String key,
Object value)
Add an item to the cache, nontransactionally, with
failfast semantics
|
long |
size()
返回该缓存区域中,内存存储对象的最大数量
|
long |
ttl()
返回该缓存区域的 TTL 设置(单位:秒)
|
public EhCache3(String name, org.ehcache.Cache<String,Object> cache, CacheExpiredListener listener)
public long ttl()
Level1Cache
ttl
in interface Level1Cache
public long size()
Level1Cache
size
in interface Level1Cache
public Object get(String key)
Cache
public void put(String key, Object value)
Cache
public Map<String,Object> get(Collection<String> keys)
Cache
public Collection<String> keys()
Cache
public void evict(String... keys)
Cache
public void clear()
Cache
public void onEvent(org.ehcache.event.CacheEvent cacheEvent)
onEvent
in interface org.ehcache.event.CacheEventListener
Copyright © 2018. All rights reserved.