I am starting to use Redis as a cache and I am not sure of the best structure for my application. The overall structure is below:
Some things I need to be able to do are:
- Flushing everything for a data source (all users and all queries).
- Flushing everything for a particular user (e.x: I would need to remove user 1 and it's queries from data source 1 and data source 2).
Everything listed in the tree is meant to be a part of the key to accessing the results of running the query for the user on the specific data source. I am new to Redis and have been going back and forth between using Hashes and Sets.
Option 1 (Sets):
DataSource1 => user1, user2, user3, user4
DataSource1:user1 => Query1, Query2, Query3
DataSource1:user1:Query1 => Results
Flushing things would be expensive because I would have to find all keys that match user1 or DataSource1.
Partial Option 2 (Hashes):
users:user1 DataSource1:Query1 Results1 DataSource2:Query1 Results2
Still not sure how flushing data sources or users would work here.
Does anyone have other thoughts/modifications?
