Redis版本问题
小编在做redis缓存token时碰到的版本问题:
解决办法就是不加set(key,value,time,?????) 或者升级到2.6以上
只加前三个参数
我的redis版本 2.4.5
org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR unknown command ‘PSETEX’
@Test
void contextLoads() throws JSONException, ParseException {
redisTemplate.opsForValue().set("token","token xxx");
System.out.println("没有时间单位参数:"+this.hasKey("token"));
redisTemplate.opsForValue().set("token","token1", 20000,TimeUnit.MILLISECONDS);
System.out.println("有时间单位参数:");
System.out.println(this.hasKey("token"));
}