I would like to save some information as follows (note that I am not tied to this data structure at all, but it shows you the basic information that I want to save):
{ user_id: 12345, page_id: 2, country: 'DE' }
In these entries, user_id is a unique field, but page_id is not.
I would like to translate this into a Redis data structure, and I would like to be able to run efficient search queries as follows:
- For user_id 12345, find the appropriate country.
- For page_id 2, find all related user_id and their countries.
Is it possible to do this in Redis? If so, what data structures should I use, and how should I avoid the possibility of duplicate records when I insert them?
source
share