Class TimedCache<K,V>
java.lang.Object
org.miaixz.bus.core.cache.provider.AbstractCache<K,V>
org.miaixz.bus.core.cache.provider.StampedCache<K,V>
org.miaixz.bus.core.cache.provider.TimedCache<K,V>
- Type Parameters:
K- 键类型V- 值类型
- All Implemented Interfaces:
Serializable,Iterable<V>,Cache<K,V>
- Direct Known Subclasses:
WeakCache
定时缓存 此缓存没有容量限制,对象只有在过期后才会被移除
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class org.miaixz.bus.core.cache.provider.StampedCache
lockFields inherited from class org.miaixz.bus.core.cache.provider.AbstractCache
cacheMap, capacity, existCustomTimeout, hitCount, keyLockMap, listener, missCount, timeout -
Constructor Summary
ConstructorsConstructorDescriptionTimedCache(long timeout) 构造TimedCache(long timeout, Map<Mutable<K>, CacheObject<K, V>> map) 构造 -
Method Summary
Modifier and TypeMethodDescriptionvoid取消定时清理protected int清理过期对象TimedCache<K, V> schedulePrune(long delay) 定时清理Methods inherited from class org.miaixz.bus.core.cache.provider.StampedCache
cacheObjIterator, clear, containsKey, get, prune, put, removeMethods 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, timeout, toStringMethods 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
-
TimedCache
public TimedCache(long timeout) 构造- Parameters:
timeout- 超时(过期)时长,单位毫秒
-
TimedCache
构造- 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()取消定时清理
-