J
J
joger2013-09-26 15:36:03
PHP
joger, 2013-09-26 15:36:03

Redis: how to EXPIRE a set?

Task: logging the site on redis
My solution: all logs are written in redis with a TTL of 30 minutes. every 10 minutes a script is run that gets the averages for 10 minutes and stores them in MySQL.
In Redis, keys are UNIX TIMESTAMP and Set is made up of events. happened in this second.
Problem: I can't put EXPIRE on a Set that is constantly updated.
those.
RPUSH 'a' 'b'
EXPIRE 'a' 120
RPUSH 'a' 'c'
EXPIRE 'a' 120
LRANGE 'a' 0 -1 => 'c'
because any RPUSH after EXPIRE kills the previous value.

Maybe I didn't see something?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EugeneOZ, 2013-09-27
@EugeneOZ

oops, sorry, I completely misunderstood the question - forget the previous answer :)
answer 2: radish has a TTL function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question