K - 键类型V - 值类型public class FIFOCache<K,V> extends ReentrantCache<K,V>
元素不停的加入缓存直到缓存满为止,当缓存满时,清理过期缓存对象,清理后依旧满则删除先入的缓存(链表首部对象)
优点:简单快速
缺点:不灵活,不能保证最常用的对象总是被保留
lockcacheMap, capacity, existCustomTimeout, hitCount, keyLockMap, listener, missCount, timeout| Constructor and Description |
|---|
FIFOCache(int capacity)
构造,默认对象不过期
|
FIFOCache(int capacity,
long timeout)
构造
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
pruneCache()
先进先出的清理策略
先遍历缓存清理过期的缓存对象,如果清理后还是满的,则删除第一个缓存对象 |
cacheObjIterator, clear, containsKey, get, get, prune, put, remove, toStringcacheObjIter, capacity, get, getHitCount, getMissCount, getWithoutLock, isEmpty, isFull, isPruneExpiredActive, iterator, keySet, onRemove, put, putWithoutLock, removeWithoutLock, setListener, size, timeoutclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic FIFOCache(int capacity)
capacity - 容量public FIFOCache(int capacity,
long timeout)
capacity - 容量timeout - 过期时长protected int pruneCache()
pruneCache in class AbstractCache<K,V>Copyright © 2025. All rights reserved.