redisTemplate超时设置

刺骨的言语ヽ痛彻心扉 2022-07-17 16:22 853阅读 0赞

redistempalate的超时设置时,一定要每次用set写入时,更新超时,不然默认会失效的。

例如:

int tempTime = this.redisTemplate.getExpire(“max”).intValue();
tempCount = this.redisTemplate.opsForValue().get(“max”)-1;
this.redisTemplate.opsForValue().set(“max”, tempCount);
this.redisTemplate.expire(“max”,tempTime,TimeUnit.SECONDS);

发表评论

表情:
评论列表 (有 0 条评论,853人围观)

还没有评论,来说两句吧...

相关阅读