From 1edc2fc69f10c2059f6f5db52e32cd7e25e38a26 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 7 Aug 2022 19:30:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=A0=E9=99=A4Hash?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=9F=90=E6=9D=A1=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/framework/redis/RedisCache.java | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/ruoyi/framework/redis/RedisCache.java b/src/main/java/com/ruoyi/framework/redis/RedisCache.java index 1e674db..da5329a 100644 --- a/src/main/java/com/ruoyi/framework/redis/RedisCache.java +++ b/src/main/java/com/ruoyi/framework/redis/RedisCache.java @@ -61,6 +61,19 @@ public class RedisCache return expire(key, timeout, TimeUnit.SECONDS); } + /** + * 设置有效时间 + * + * @param key Redis键 + * @param timeout 超时时间 + * @param unit 时间单位 + * @return true=设置成功;false=设置失败 + */ + public boolean expire(final String key, final long timeout, final TimeUnit unit) + { + return redisTemplate.expire(key, timeout, unit); + } + /** * 获取有效时间 * @@ -83,19 +96,6 @@ public class RedisCache return redisTemplate.hasKey(key); } - /** - * 设置有效时间 - * - * @param key Redis键 - * @param timeout 超时时间 - * @param unit 时间单位 - * @return true=设置成功;false=设置失败 - */ - public boolean expire(final String key, final long timeout, final TimeUnit unit) - { - return redisTemplate.expire(key, timeout, unit); - } - /** * 获得缓存的基本对象。 * @@ -255,6 +255,18 @@ public class RedisCache return redisTemplate.opsForHash().multiGet(key, hKeys); } + /** + * 删除Hash中的某条数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @return 是否成功 + */ + public boolean deleteCacheMapValue(final String key, final String hKey) + { + return Boolean.TRUE.equals(redisTemplate.opsForHash().delete(key, hKey)); + } + /** * 获得缓存的基本对象列表 *