java.lang.Object
org.miaixz.bus.cache.metric.RedisCache<K,V>
- Type Parameters:
K- 键类型V- 值类型
- All Implemented Interfaces:
CacheX<K,V>
Redis 单机缓存支持
基于Jedis客户端实现的Redis单机缓存接口,提供分布式缓存功能。 支持序列化和反序列化操作,并提供批量读写操作。 使用@PreDestroy注解确保资源正确释放。
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
ConstructorsConstructorDescriptionRedisCache(redis.clients.jedis.JedisPool jedisPool) 构造方法RedisCache(redis.clients.jedis.JedisPool jedisPool, BaseSerializer serializer) 构造方法 -
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
-
RedisCache
public RedisCache(redis.clients.jedis.JedisPool jedisPool) 构造方法使用指定的Jedis连接池和默认的Hessian2序列化器创建缓存实例
- Parameters:
jedisPool- Jedis连接池
-
RedisCache
构造方法使用指定的Jedis连接池和序列化器创建缓存实例
- Parameters:
jedisPool- Jedis连接池serializer- 序列化器
-
-
Method Details
-
read
从缓存中读取单个值 -
write
向缓存中写入单个键值对 -
read
从缓存中批量读取值 -
write
向缓存中批量写入键值对 -
remove
从缓存中移除指定的键 -
clear
public void clear()清空缓存 -
tearDown
@PreDestroy public void tearDown()销毁方法使用@PreDestroy注解,在Bean销毁时关闭Jedis连接池
-