java.lang.Object
org.miaixz.bus.cache.metric.GuavaCache<K,V>
- Type Parameters:
K- 键类型V- 值类型
- All Implemented Interfaces:
CacheX<K,V>
Guava 缓存支持
基于Google Guava Cache实现的缓存接口,提供本地缓存功能。 支持设置最大容量、过期时间等配置参数,并提供批量读写操作。
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
ConstructorsConstructorDescriptionGuavaCache(long size, long expire) 构造方法GuavaCache(long size, long expire, com.google.common.cache.CacheLoader<K, V> cacheLoader) 构造函数(支持异步加载)GuavaCache(Properties properties) 构造方法 -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.miaixz.bus.cache.CacheX
containsKey, write
-
Constructor Details
-
GuavaCache
public GuavaCache(long size, long expire) 构造方法使用指定的大小和过期时间创建缓存实例
- Parameters:
size- 缓存最大容量expire- 过期时间(毫秒)
-
GuavaCache
构造方法使用Properties配置创建缓存实例,支持配置最大容量、过期时间等参数
- Parameters:
properties- 配置属性
-
GuavaCache
构造函数(支持异步加载)使用指定的大小、过期时间和缓存加载器创建缓存实例
- Parameters:
size- 最大缓存条目数expire- 过期时间(毫秒)cacheLoader- 缓存加载器
-
-
Method Details
-
read
从缓存中读取单个值 -
read
从缓存中批量读取值 -
write
向缓存中写入单个键值对 -
write
向缓存中批量写入键值对 -
remove
从缓存中移除指定的键 -
clear
public void clear()清空缓存
-