Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question