What’s default TTL in Redis?
There is no default TTL. By default, keys are set to live forever.
There is no default TTL. By default, keys are set to live forever.
Who said that you should actually store anything in redis key? Empty string “” is a perfectly valid value for a redis key, and it’s a shortest possible one: > SET foo “” OK > GET foo “” > BITCOUNT foo (integer) 0
I was also looking for this kind of operation. I didn’t find anything, so I did it with MULTI/EXEC: MULTI expire key1 expire key2 expire key3 EXEC
No, this isn’t possible (and not planned either). The recommended approach is to use an ordered set with score set to timestamp and then manually removing expired keys. To query for non-expired keys, you can use ZRANGEBYSCORE $now +inf, to delete expired keys, ZREMRANGEBYSCORE -inf $now will do the trick. In my application, I simply … Read more
There is no built in expiration feature but if your goal is to automatically expire fields and have the logic contained within your database (and thus no outside dependency like a cron job) then you can always write a trigger. Below is an example of a trigger that deletes rows from a table that have … Read more