org.springframework.data.redis.core.RedisTemplate 查一个key的哈希怎么查
org.springframework.data.redis.core.RedisTemplate查一个key的哈希怎么查...
org.springframework.data.redis.core.RedisTemplate 查一个key的哈希怎么查
展开
1个回答
展开全部
@Test
public void queryCacheKey() throws Exception{
String key = "00000002";
String hashKey = "513117070";
//校验哈希key是否存在,存在为true,反之false
Boolean hasKey = redisTemplate.opsForHash().hasKey(key, hashKey);
System.out.println(hasKey);
if(hasKey){
//取值
Object object = redisTemplate.opsForHash().get(key, hashKey);
System.out.println("取出存储key-value:" + object.toString());
}
}
public void queryCacheKey() throws Exception{
String key = "00000002";
String hashKey = "513117070";
//校验哈希key是否存在,存在为true,反之false
Boolean hasKey = redisTemplate.opsForHash().hasKey(key, hashKey);
System.out.println(hasKey);
if(hasKey){
//取值
Object object = redisTemplate.opsForHash().get(key, hashKey);
System.out.println("取出存储key-value:" + object.toString());
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询