
在spring中 针对 RedisTemplate类:
private RedisTemplate<String, String> template;
当调用下面方法
template.opsForValue().set(key, value,times, timeUnit);
当指定timeUnit为TimeUnit.MILLISECONDS 将抛出下面异常
redis.clients.jedis.exceptions.JedisDataException: ERR unknown command 'PSETEX'
原因:
因为redis版本过低 我的redis版本为2点几的,不支持毫秒级别及以下的 过期时间类型
将redis版本升级到3 就没事了