From b50de64528f0db651d3aaa2b056735ca2d6348d9 Mon Sep 17 00:00:00 2001 From: yyb <1416014977@qq.com> Date: Wed, 28 Jan 2026 09:38:12 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=96=B0=E5=A2=9Ehash=20=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lease/redis/service/RedisService.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/main/java/com/m2pool/lease/redis/service/RedisService.java b/src/main/java/com/m2pool/lease/redis/service/RedisService.java index a59b174..2b1656b 100644 --- a/src/main/java/com/m2pool/lease/redis/service/RedisService.java +++ b/src/main/java/com/m2pool/lease/redis/service/RedisService.java @@ -274,6 +274,47 @@ public class RedisService { redisTemplate.opsForHash().put(key, hKey, value); } + + + /** + * 往Hash中存入数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @param value 值 + */ + public void setCacheMapValue7(final String key, final String hKey, final T value) + { + redisTemplate7.opsForHash().put(key, hKey, value); + } + + /** + * 往Hash中存入数据(带过期时间) + * + * @param key Redis键 + * @param hKey Hash键 + * @param value 值 + * @param timeout 过期时间 + * @param timeUnit 时间单位 + */ + public void setCacheMapValue7(final String key, final String hKey, final T value, final Long timeout, final TimeUnit timeUnit) + { + redisTemplate7.opsForHash().put(key, hKey, value); + redisTemplate7.expire(key, timeout, timeUnit); + } + + /** + * 删除Hash中的数据(批量删除) + * + * @param keyFieldMap Redis键和Hash键的映射,key=Redis键,value=Hash键 + */ + public void deleteCacheMapValue7(final Map keyFieldMap) { + keyFieldMap.forEach((key, hKey) -> { + redisTemplate7.opsForHash().delete(key, hKey); + }); + } + + /** * 获取Hash中的数据 *