是否可以在不删除现有 ttl 的情况下SET
redis 键?目前我知道的唯一方法是找出 ttl 并执行 SETEX
但这似乎不太准确。
最佳答案
KEEPTTL选项将添加到redis>=6.0的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/