node.js - Redis - How to expire key daily -
i know expireat in redis used specify when key expire. problem though takes absolute unix timestamp. i'm finding hard time thinking should set argument if want key expire @ end of day.
this how set key:
client.set(key, body);
so set expire at:
client.expireat(key, ???);
any ideas? i'm using nodejs , sailsjs thanks!
if want expire 24 hrs later
client.expireat(key, parseint((+new date)/1000) + 86400);
or if want expire @ end of today, can use .sethours
on new date()
object time @ end of day, , use that.
var todayend = new date().sethours(23, 59, 59, 999); client.expireat(key, parseint(todayend/1000));
Comments
Post a Comment