Class WeakCache<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>
org.miaixz.bus.core.cache.provider.WeakCache<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.StampedCache
lockFields inherited from class org.miaixz.bus.core.cache.provider.AbstractCache
cacheMap, capacity, existCustomTimeout, hitCount, keyLockMap, listener, missCount, timeout -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.miaixz.bus.core.cache.provider.TimedCache
cancelPruneSchedule, pruneCache, schedulePruneMethods 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, 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
-
WeakCache
public WeakCache(long timeout) 构造- Parameters:
timeout- 超时时常,单位毫秒,-1或0表示无限制
-
-
Method Details
-
setListener
Description copied from class:AbstractCache设置监听- Specified by:
setListenerin interfaceCache<K,V> - Overrides:
setListenerin classAbstractCache<K,V> - Parameters:
listener- 监听- Returns:
- this
-