gpt4 book ai didi

redis - 如何在不影响剩余 TTL 的情况下更新 Redis 值?

转载 作者:IT王子 更新时间:2023-10-29 05:55:29 31 4
gpt4 key购买 nike

是否可以在不删除现有 ttl 的情况下SET redis 键?目前我知道的唯一方法是找出 ttl 并执行 SETEX 但这似乎不太准确。

最佳答案

KEEPTTL选项将添加到redis>=6.0的SET

https://redis.io/commands/set

https://github.com/antirez/redis/pull/6679

The SET command supports a set of options that modify its behavior:

EX seconds -- Set the specified expire time, in seconds.
PX milliseconds -- Set the specified expire time, in milliseconds.
NX -- Only set the key if it does not already exist.
XX -- Only set the key if it already exist.
(!) KEEPTTL -- Retain the time to live associated with the key.

关于redis - 如何在不影响剩余 TTL 的情况下更新 Redis 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21897337/

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