I would like to know if it is possible to set a TTL on one or more key of a list (any kind of list) or a set in Redis 3+. What is a good alternative in case it doesn't handle it. I have found an old question about sets but it is from 2013 so it may be irrelevant with the new releases. Thanks
Asked
Active
Viewed 53 times
0
-
Looks like the redis doc is straightforward: http://redis.io/commands/ttl : `SET mykey "Hello" EXPIRE mykey 10TTL mykey ==> 10` (since version 1.0) – fukanchik Mar 30 '16 at 23:35
-
@fukanchik I am asking for a key wich is a member of a list or a set. – William Poussier Mar 30 '16 at 23:35
-
No, this is still the same as it was - no expiry for data structures' elements. Yet. – Itamar Haber Mar 30 '16 at 23:43
-
@ItamarHaber Thansk and i will take not of your comment on this blog post : https://quickleft.com/blog/how-to-create-and-expire-list-items-in-redis/ The trim of the list sounds great. – William Poussier Mar 30 '16 at 23:47
-
I think you can emulate this using compound keys: `SETNAME+"."+KEY`. This would be `EXPIRE`able. The syntax of `LRANGE` should be replaced with `KEYS "SETNAME.*"` – fukanchik Mar 30 '16 at 23:48
-
@fukanchik Thanks for the tip, i will also consider this. – William Poussier Mar 30 '16 at 23:50
-
Never. Ever. Use. `KEYS`. (in production). – Itamar Haber Mar 30 '16 at 23:52
-
@William - I remember that one, issue 41 of Redis Watch :) – Itamar Haber Mar 30 '16 at 23:54