TimedMap.EventListener<K,V>| 限定符和类型 | 字段和说明 |
|---|---|
protected org.slf4j.Logger |
log |
| 构造器和说明 |
|---|
TimedMapImpl()
默认最大2个线程处理监听器
迭代的时候也更新ttl
|
TimedMapImpl(boolean iteratorUpdate) |
TimedMapImpl(Executor lisenterExecutor,
boolean iteratorUpdate)
建议线程池固定大小,否则移除事件过多会消耗很多线程资源
|
| 限定符和类型 | 方法和说明 |
|---|---|
Map<K,V> |
cleanExpire()
清理过期,返回被清理的键值对
不需要不定时清理,建议在容量达到某大小时清理
|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object key) |
V |
getBy(K key) |
Runnable |
getCleanTask()
获取清理超时的任务,执行后将会触发监听器执行
|
long |
getExpireTime(K key)
获取过期时间,此访问不会更新活动时间
|
boolean |
isEmpty() |
boolean |
isIteratorUpdate() |
Set<K> |
keySet() |
V |
put(K key,
V value) |
V |
put(K key,
V value,
long ttl)
存放一个键值对,该键值超时访问自动删除
|
V |
put(K key,
V value,
long ttl,
TimedMap.EventListener<K,V> listener) |
void |
putAll(Map<? extends K,? extends V> m) |
V |
remove(Object key) |
protected net.jueb.util4j.collection.map.TimedMapImpl.TimedEntry<K,V> |
removeAndListener(Object key,
boolean expire)
移除缓存对象并通知事件
|
V |
removeBy(K key) |
V |
setEventListener(K key,
TimedMap.EventListener<K,V> lisnener)
给键值对加事件监听器
|
void |
setIteratorUpdate(boolean iteratorUpdate) |
int |
size() |
V |
updateTTL(K key,
long ttl)
更新最大不活动间隔时间
|
Collection<V> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllpublic TimedMapImpl()
public TimedMapImpl(boolean iteratorUpdate)
iteratorUpdate - 是否在迭代的时候也更新ttlpublic TimedMapImpl(Executor lisenterExecutor, boolean iteratorUpdate)
lisenterExecutor - 指定处理超时监听的executoriteratorUpdate - 是否在迭代的时候也更新ttlpublic Runnable getCleanTask()
getCleanTask 在接口中 TimedMap<K,V>public Map<K,V> cleanExpire()
TimedMapcleanExpire 在接口中 TimedMap<K,V>protected net.jueb.util4j.collection.map.TimedMapImpl.TimedEntry<K,V> removeAndListener(Object key, boolean expire)
key - expire - 是否超时才执行的移除public boolean isIteratorUpdate()
public void setIteratorUpdate(boolean iteratorUpdate)
public boolean containsKey(Object key)
containsKey 在接口中 Map<K,V>public boolean containsValue(Object value)
containsValue 在接口中 Map<K,V>public long getExpireTime(K key)
getExpireTime 在接口中 TimedMap<K,V>public V setEventListener(K key, TimedMap.EventListener<K,V> lisnener)
TimedMapsetEventListener 在接口中 TimedMap<K,V>Copyright © 2020. All rights reserved.