如何在Java中使用Redisson客户端更新条目的存活时间?

huangapple go评论71阅读模式
英文:

How to update time-to-live of an entry using Redisson client in Java?

问题

让我们假设我想使用RMapCacheReactive和Redisson将一个对象A存储在Redis中。一开始,我通过键B将它放入了带有10,000毫秒TTL的映射中。紧接着,我又通过相同的键B将相同的对象A放入映射中,但TTL设置为零。

根据文档,put方法“将由指定的生存时间映射的值存储起来”,所以我的期望是A将永久存储在该映射中。然而,实际上在过去的10,000毫秒后它被移除了(使用Redisson客户端无法再获取它)。我是不是理解错了什么?

我在Redisson的3.13.4和3.12.5版本上检查了这种行为。

英文:

Let's say I'd like to store an object A in Redis using RMapCacheReactive and Redisson.
In the beginning, I put it into the map with 10 000 ms TTL by the key B. Right after that, I put the same object A by the same key B but with zero TTL.
According to the documentation, the put method "stores value mapped by the key with a specified time to live" so my expectation was that A would be stored in that map permanently.
However, it was actually removed after that 10 000 ms passed (it became impossible to get it using Redisson client).
Is there a thing that I got wrong?

I checked this behaviour on 3.13.4 and 3.12.5 versions of Redisson.

答案1

得分: 1

我在 GitHub 上报告了这个问题,链接:https://github.com/redisson/redisson/issues/3078。结果发现这是一个应该在下一个版本(3.13.5)中修复的错误。

英文:

I reported this issue on GitHub https://github.com/redisson/redisson/issues/3078. Turned out that that was a bug that should be fixed in the next version (3.13.5).

huangapple
  • 本文由 发表于 2020年9月22日 18:57:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/64008276.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定