Issue
I have updated my Redis verison to "^4.2.0" in Node and I have to convert my old client.set methods to use the options object instead of comma separated options.
I have been able to do this with setting a value because the documentation says the key titles for expiring is "EX" like...
const setValue = async (key, value, exp) => {
await client.set(key, JSON.stringify(value), { EX: exp })
}
But what are the options object key titles for "KEEPTTL" & "XX" (update if present)??? See question marks below...
const updateValue = async (key, value) => {
await client.set(key, JSON.stringify(value), { <?>: "KEEPTTL", <?>: "XX" })
}
Solution
XX
means only set the key, if the key already exists, i.e. do not add a new key.
KEEPTTL
is a new option Redis 6.0. By default, when you call set key value
on a key, the expiration time (TTL) will be reset, i.e. no TTL any more. However, with this option, you can only change the value, without modifying the TTL.
Answered By - for_stack Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.