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

标签 redis node-redis

是否可以在不删除现有 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/

相关文章:

join - 如何在 Redis 中执行 "left join"?

node.js - redis.lindex() 返回 true 而不是索引处的值

javascript - Redis SCAN 没有给出 NodeJS 中的所有匹配项

c# - 如何使用 .NET 4.5 异步和流式处理将 Blob 数据存储在 Redis 上?

python - Redis python中的HashMap过期?

javascript - connect-redis 连接到 localhost 而不管提供的主机

node.js - ExpressJS : What do I do when redis is down?

使用 Redis pub sub 和 socket io 的 Laravel 广播需要超过 2 秒才能传送

redis - 数以千计的REDIS排序集VS数百万个简单集

javascript - 锁的基本逻辑——互斥