java springboot redis StringRedisTemplate 使用方法-记录
import org.springframework.data.redis.core.StringRedisTemplate; @Autowired private StringRedisTemplate stringRedisTemplate; public static final String CACHE_KEY = "cache:key:"; //检查缓存是否存在 Boolean isExist = this.stringRedisTemplate.hasKey(key); //获取缓存 this.stringRedisTemplate.opsForValue().get(key); //设置缓存 this.stringRedisTemplate.opsForValue().set(key, "缓存内容", 30, TimeUnit.DAYS);