gpt4 book ai didi

通过具有过去时间戳的 EXPIREAT 命令的 Redis key 过期事件

转载 作者:可可西里 更新时间:2023-11-01 11:24:44 30 4
gpt4 key购买 nike

根据 redis 文档:

EXPIREAT has the same effect and semantic as EXPIRE, but instead of specifying the number of seconds representing the TTL (time to live), it takes an absolute Unix timestamp (seconds since January 1, 1970). A timestamp in the past will delete the key immediately.

在设置过去的时间戳时,除了没有抛出 key 过期事件外,我得到的行为与文档完全相同。

redis> SET mykey "Hello"
"OK"
redis> EXISTS mykey
(integer) 1
redis> EXPIREAT mykey 1293840000
(integer) 1
redis> EXISTS mykey
(integer) 0

当我在 EXPIREAT 命令中设置 future 时间戳时,它会在 key 过期时抛出 key 过期事件。

那么通过EXPIREAT设置过去的时间戳是不是不支持获取key过期事件?

最佳答案

在您的情况下,没有过期事件。

So is it not supported to get key expiry event while setting past timestamp through EXPIREAT?

事实上,这取决于。

如果您的 Redis 正在加载数据或者它是从服务器,Redis 会为给定的键设置过期时间,并发布一个expire 事件。否则,Redis 删除或取消链接给定的键,并发布一个 del 事件。

因此,在您的情况下,您将获得一个 del 事件。

关于通过具有过去时间戳的 EXPIREAT 命令的 Redis key 过期事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49567257/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com