java.lang.Object
org.miaixz.bus.core.cache.provider.AbstractCache<K,V>
org.miaixz.bus.core.cache.provider.LockedCache<K,V>
org.miaixz.bus.core.cache.provider.TimedReentrantCache<K,V>
- Type Parameters:
K- 键类型V- 值类型
- All Implemented Interfaces:
Serializable,Iterable<V>,Cache<K,V>
定时缓存, 此缓存没有容量限制,对象只有在过期后才会被移除
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class org.miaixz.bus.core.cache.provider.LockedCache
lockFields inherited from class org.miaixz.bus.core.cache.provider.AbstractCache
cacheMap, capacity, existCustomTimeout, hitCount, keyLockMap, listener, missCount, timeout -
Constructor Summary
ConstructorsConstructorDescriptionTimedReentrantCache(long timeout) 构造TimedReentrantCache(long timeout, Map<Mutable<K>, CacheObject<K, V>> map) 构造 -
Method Summary
Modifier and TypeMethodDescriptionvoid取消定时清理protected int清理过期对象schedulePrune(long delay) 定时清理Methods inherited from class org.miaixz.bus.core.cache.provider.LockedCache
cacheObjIterator, clear, containsKey, get, prune, put, remove, toStringMethods inherited from class org.miaixz.bus.core.cache.provider.AbstractCache
cacheObjIter, capacity, get, get, getHitCount, getMissCount, getWithoutLock, isEmpty, isFull, isPruneExpiredActive, iterator, keySet, onRemove, put, putWithoutLock, removeWithoutLock, setListener, size, timeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TimedReentrantCache
public TimedReentrantCache(long timeout) 构造- Parameters:
timeout- 超时(过期)时长,单位毫秒
-
TimedReentrantCache
构造- Parameters:
timeout- 过期时长map- 存储缓存对象的map
-
-
Method Details
-
pruneCache
protected int pruneCache()清理过期对象- Specified by:
pruneCachein classAbstractCache<K,V> - Returns:
- 清理数
-
schedulePrune
定时清理- Parameters:
delay- 间隔时长,单位毫秒- Returns:
- this
-
cancelPruneSchedule
public void cancelPruneSchedule()取消定时清理
-