When you update an item in Redis, there's no real difference than setting it for the first time. That means that the expire time (TTL) on the original record will be lost, but if you are updating you may want to retain the value to where it's at now. I originally posted this on stackoverflow but I'm also posting it here in case you find it useful
If you are using the ioredis client API, then you can set a value and its expire time in the same call, like this
if you just do this, the item won't expire.
But in this example, I want to set the expire time to whatever it currently is. The expire time can be retrieved like this
As usual, I'm using Promises, and also I'll stringify the content if it comes over as an object.
the optional expire argument can take these values
>0 - use as the new expire time for the item
0 - use the existing TTL as the expire time. If there is no expire time, or the item doesn't exist there will be no expiry
undefined - no expiry
So to update an objecy and retain the current TTL :-
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > React, redux, redis, material-UI and firebase >