1.往指定key中存储 键值
redisTemplate.boundHashOps("demo").put("1",1);
-
根据指定key中得键取出值
System.out.println(redisTemplate.boundHashOps("demo").get("1"));
3.根据指定key中得键删除
redisTemplate.boundHashOps("demo").delete("1");
4.根据指定key取出全部键值对
Map<Object, Object> entries = redisTemplate.boundHashOps("demo").entries();
System.out.println(entries);
-
根据指定key取出所有键
Set<Object> keys = redisTemplate.boundHashOps("demo").keys();
System.out.println(keys);
6.批量存储到指定key中
Map<String,String> map = new HashMap<>();
map.put("3","zhangsan");
map.put("4","lisi");
redisTemplate.boundHashOps("demo").putAll(map);
7.获取指定key得元素长度
Long size = redisTemplate.boundHashOps("demo").size();
System.out.println(size);
8.判断指定key中是否存在该键
System.out.println(redisTemplate.boundHashOps("demo").hasKey("1"));
9.获取指定key中所有键值对得值
List<Object> values = redisTemplate.boundHashOps("demo").values();
System.out.println(values);
10.根据指定key中的键 每次重复自增大小 (整型)
Long increment = redisTemplate.boundHashOps("demo").increment("1", 1);
System.out.println(increment);
11.根据指定key中的键 每次重复自增大小 (小数类型)
Double aDouble = redisTemplate.boundHashOps("demo").increment("1", 1.1);
System.out.println(aDouble);
12.根据指定key判断键是否存在,存在返回false不新增,不存在则新增键值对返回true
System.out.println(redisTemplate.boundHashOps("demo").putIfAbsent("7", 5));
13.设置key得到期时间 TimeUnit 设置时间类型(时、分、秒...)
redisTemplate.boundHashOps("demo").expire(100000, TimeUnit.MILLISECONDS);
14.重新命名当前key得名称
redisTemplate.boundHashOps(key).rename("test");
15.获取当前key的存储方式
System.out.println(redisTemplate.boundHashOps("demo").getType());
16.获取当前key过期时间
System.out.println(redisTemplate.boundHashOps("demo").getExpire());