0

I'm looking for a way to maintain a hash map of values however I want the values (not the whole map) to expire individually after a a period of time.

The reason I'd like to accomplish this is because it drastically simplifies and minimizes my dependency on a database and time checking. Basically I'd like to define a list of resources to poll for 10 minutes after they are first requested.

So say my list is: ItemA, ItemB, ItemC.

ItemA is now older than 10 minutes, it should be knocked off the list so that the new list when I request it is only ItemB and ItemC.

I'm using a Node package with the standard redis library, so I'm looking for a way to do this easily with those packages. If not I'll fall back to the db method, but getting this working with Redis would be really great.

I'm already successfully using this to expire session tokens and from what I've read you can't do this directly with hashmap values. Just curious what some workarounds could look like.

Thanks.

ddibiase
  • 1,412
  • 1
  • 20
  • 44
  • 1
    See here for a possible solution using Sorted Sets: http://stackoverflow.com/questions/24105074/redis-to-set-timeout-for-a-key-value-pair-in-set/24105394#24105394 – Itamar Haber Jul 18 '15 at 21:50
  • possible duplicate of [set expiry for Hashmap values in Redis?](http://stackoverflow.com/questions/20287739/set-expiry-for-hashmap-values-in-redis) – Basit Anwer Aug 15 '15 at 14:09
  • It is, someone should clean this up. – ddibiase Aug 15 '15 at 14:26

0 Answers0