Reputation:
I know there are several ways to set a specific ttl for a key, but is there a way to add some extra time for a key which has a counting down ttl?
Upvotes: 2
Views: 4689
Reputation: 1121
Upvotes: 1
Reputation: 22906
There's no built-in way to extend TTL. You need to get the current TTL, and then add some more TTL to it.
Wrap these two steps into a Lua script:
-- extend 300 seconds
eval 'local ttl = redis.call("TTL", "key") + 300; redis.call("EXPIRE", "key", ttl)' 0
Upvotes: 2