Class CacheUtil
java.lang.Object
com.sure.tool.cache.CacheUtil
缓存门面:快速创建各种策略缓存,参考 Hutool 的
CacheUtil 设计。
English: Factory and convenience methods for the built-in cache implementations.
- Since:
- 0.1.0
- Author:
- suretool
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> FifoCache <K, V> newFifoCache(int capacity) 创建 FIFO 缓存。static <K,V> LfuCache <K, V> newLfuCache(int capacity) 创建 LFU 缓存。static <K,V> LruCache <K, V> newLruCache(int capacity) 创建 LRU 缓存。static <K,V> TimedCache <K, V> newTimedCache(long defaultTimeout) 创建定时过期缓存。static <K,V> WeakCache <K, V> 创建弱引用缓存(值可被 GC 回收,自动清理)。static <K,V> WeakCache <K, V> newWeakCache(int capacity, long defaultTimeout) 创建弱引用缓存。
-
Method Details
-
newFifoCache
创建 FIFO 缓存。- Type Parameters:
K- 键类型V- 值类型- Parameters:
capacity- 容量- Returns:
- 缓存
-
newLruCache
创建 LRU 缓存。- Type Parameters:
K- 键类型V- 值类型- Parameters:
capacity- 容量- Returns:
- 缓存
-
newLfuCache
创建 LFU 缓存。- Type Parameters:
K- 键类型V- 值类型- Parameters:
capacity- 容量- Returns:
- 缓存
-
newTimedCache
创建定时过期缓存。- Type Parameters:
K- 键类型V- 值类型- Parameters:
defaultTimeout- 默认存活时间(毫秒)- Returns:
- 缓存
-
newWeakCache
创建弱引用缓存(值可被 GC 回收,自动清理)。- Type Parameters:
K- 键类型V- 值类型- Returns:
- 缓存
-
newWeakCache
创建弱引用缓存。- Type Parameters:
K- 键类型V- 值类型- Parameters:
capacity- 容量上限,<=0 表示无上限defaultTimeout- 默认存活时间(毫秒),<=0 表示不过期- Returns:
- 缓存
-