Question: 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.

Answer: 
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 be `end_time_of_event`

Let's call them `start_events` and `end_events` respectively.

Add:

```
ZADD start_events start_time event
ZADD end_events end_time event

```

Search

```
-- randomly generate a destination id, search the events 
-- and store in that based on the start time

ZRANGESTORE random-start-time-dst start_events 0 current_time

-- randomly generate a destination id for end-time search, post filter 
-- store results in that destination

ZRANGESTORE random-end-time-dst end_events current_time+7.weeks -1

-- Take the intersection of these two sets
ZINTER INT_MAX random-start-time-dst random-end-time-dst 

-- Delete the newly created collections to  free up the memory 
DEL random-start-time-dst
DEL random-end-time-dst

```
Another option would be to use [zeeSQL](https://zeesql.com) 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.