update 新增hash 操作方法
This commit is contained in:
@@ -274,6 +274,47 @@ public class RedisService {
|
|||||||
redisTemplate.opsForHash().put(key, hKey, value);
|
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中的数据
|
* 获取Hash中的数据
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user