Template模板
@Autowired private StringRedisTemplate template; @Autowired private RedisTemplate redisTemplate;
String类型
//储存数据 template.opsForValue().set("name","yan"); System.out.println(template.opsForValue().get("name")); //值偏移 //template.opsForValue().increment("age"); template.opsForValue().decrement("age"); System.out.println(template.opsForValue().get("age")); //删除 //template.opsForValue().getOperations().delete("name"); //存储有效时间的键值对 template.opsForValue().set("name","yan",20, TimeUnit.SECONDS);
hash类型
//创建一个map集合 Map<String,Object> map = new HashMap<String,Object>(); User user1 = new User("