Package com.xxl.tool.cache.impl
Class LFUCache<K,V>
java.lang.Object
com.xxl.tool.cache.impl.ReentrantCache<K,V>
com.xxl.tool.cache.impl.LFUCache<K,V>
- All Implemented Interfaces:
Cache<K,,V> Serializable
LFU(least frequently used) 最少使用率缓存
1、元素持续添加直到存满,触发 清理全部过期对象;
2、清理后缓存仍存满时,清除最少访问(访问计数最小)的对象;并将其他对象的访问数减去这个最小访问数,以便新对象进入后可以公平计数。
3、优劣势:
- 优势,热点数据可以常驻内存;
- 劣势,复杂度较高;
- See Also:
-
Field Summary
Fields inherited from class com.xxl.tool.cache.impl.ReentrantCache
cacheMap, capacity, expireType, hitCount, listener, loader, missCount, timeout, writeLockCount, writeLockMap -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intdoPrune()1、清理全部过期对象 2、清理后缓存仍存满时,清除最少访问(访问计数最小)的对象;并将其他对象的访问数减去这个最小访问数,以便新对象进入后可以公平计数。Methods inherited from class com.xxl.tool.cache.impl.ReentrantCache
asMap, capacity, clear, containsKey, get, get, getIfPresent, hitCount, isEmpty, isFull, missCount, onRemove, prune, put, remove, removeWithoutLock, setListener, setLoader, size, timeout, toString
-
Constructor Details
-
LFUCache
public LFUCache(int capacity, long timeout, boolean expireType)
-
-
Method Details
-
doPrune
protected int doPrune()1、清理全部过期对象 2、清理后缓存仍存满时,清除最少访问(访问计数最小)的对象;并将其他对象的访问数减去这个最小访问数,以便新对象进入后可以公平计数。- Specified by:
doPrunein classReentrantCache<K,V> - Returns:
- 清理数据量
-