Package cn.sliew.milky.common.cache.lru
Class LRUCache<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<K,V>
-
- cn.sliew.milky.common.cache.lru.LRUCache<K,V>
-
- All Implemented Interfaces:
Serializable,Cloneable,Map<K,V>
public class LRUCache<K,V> extends LinkedHashMap<K,V>
最常见的缓存实现方式,缺点是缺少缓存过期功能 dubbo的实现添加了并发访问的功能- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(Object key)Vget(Object key)intgetMaxCapacity()Vput(K key, V value)Vremove(Object key)protected booleanremoveEldestEntry(Map.Entry<K,V> eldest)voidsetMaxCapacity(int maxCapacity)intsize()-
Methods inherited from class java.util.LinkedHashMap
containsValue, entrySet, forEach, getOrDefault, keySet, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, hashCode, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace
-
-
-
-
Method Detail
-
removeEldestEntry
protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
- Overrides:
removeEldestEntryin classLinkedHashMap<K,V>
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>- Overrides:
containsKeyin classHashMap<K,V>
-
size
public int size()
-
clear
public void clear()
-
getMaxCapacity
public int getMaxCapacity()
-
setMaxCapacity
public void setMaxCapacity(int maxCapacity)
-
-