Package org.aoju.bus.core.lang
Class SimpleCache<K,V>
java.lang.Object
org.aoju.bus.core.lang.SimpleCache<K,V>
- Type Parameters:
K- 键类型V- 值类型
- All Implemented Interfaces:
Serializable,Iterable<Map.Entry<K,V>>
简单缓存,无超时实现,使用
WeakMap实现缓存自动清理- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescription构造,默认使用WeakHashMap实现缓存自动清理SimpleCache(Map<K, V> initMap) 通过自定义Map初始化,可以自定义缓存实现 比如使用WeakHashMap则会自动清理key,使用HashMap则不会清理 同时,传入的Map对象也可以自带初始化的键值对,防止在get时创建 -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
keyLockMap
-
-
Constructor Details
-
SimpleCache
public SimpleCache()构造,默认使用WeakHashMap实现缓存自动清理 -
SimpleCache
通过自定义Map初始化,可以自定义缓存实现 比如使用WeakHashMap则会自动清理key,使用HashMap则不会清理 同时,传入的Map对象也可以自带初始化的键值对,防止在get时创建- Parameters:
initMap- 初始Map,用于定义Map类型
-
-
Method Details
-
get
-
get
-
get
-
put
-
remove
-
clear
public void clear()清空缓存池 -
iterator
-