My code is as shown below:
client.set(name, data, 'EX', 23 * 60 * 60, (err, reply) => {
});
What it does is , it stores the key-value for 23 hours. But is there any way , through which I can set the key to expire at 11:59 p.m. in the night?
Redis itself doesn't provide this functionality. But you can calculate the value of seconds until midnight.
Despite the accepted answer, you could use
EXPIREAT
for that. However, sinceSET
does not support this as an argument, you'll need two calls in your code.