update 新增hash 操作方法

This commit is contained in:
yyb
2026-01-28 09:38:12 +08:00
parent af55cc02cf
commit b50de64528

View File

@@ -274,6 +274,47 @@ public class RedisService {
redisTemplate.opsForHash().put(key, hKey, value);
}
/**
* 往Hash中存入数据
*
* @param key Redis键
* @param hKey Hash键
* @param value 值
*/
public <T> 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 <T> 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 <T> void deleteCacheMapValue7(final Map<String, String> keyFieldMap) {
keyFieldMap.forEach((key, hKey) -> {
redisTemplate7.opsForHash().delete(key, hKey);
});
}
/**
* 获取Hash中的数据
*