I’m new to Redis and would like to get advice from the experts on my use case. I have an event object that has start_time_of_event and end_time_of_event as two of the attributes(there are plenty more attributes in the object). I have millions of these events and need to store them in Redis so that I can query them at runtime. I was hoping to use the timestamp as key and the event object as the value. While querying, I need to get the list of events where start_time_of_event <= current_time and end_time_of_event>=1 week from now. Not sure if ZRANGE, LRANGE or any other data structure in Redis supports using multiple(complex) keys. Any suggestions on what’s the best way to achieve the above use case using Redis?
Thanks a lot in advance.
2
Answers
You should store events in two of Redis ZSETs, for one set score should be
start_time_of_event
and for another, the score would beend_time_of_event
Let’s call them
start_events
andend_events
respectively.Add:
Search
Another option would be to use zeeSQL to store those informations inside a secondary index (an SQL table).
Once those data are in a table, you can query them using standard SQL.
It would be just a simple SQL query, without the need of maintaing the Redis structures.