I have a list of Ids from a table that I want to store in a Redis sorted set. Each of these ids has a date and entity associated with it. The plan is to use the id as the score and allow Redis to sort them accordingly. When it is time for lookup I will get the max id and the min id from the table by start and end dates. Using this min and max id I can get a list of ids between them using Redis' zrangebyscore command.
entities' values = zrangebyscore ids (min max
Since the ids are sorted numerically I can reliably get all the ids belonging to my entity between two dates(min id and max id). My question is when creating my sorted set I do not know what to enter for the value in "key score value".
zadd key score value
When I create the list I do not have any information that fits well for the "value" parameter. Can this be blank or some arbitrary id?
zadd ids 123 ???
I am still rather new to Redis and any info on the subject would be greatly appreciated.
Thank you
You don't need Sorted Sets, you just need a Set:
1. define a key that is something like: entity1:ids
2. add your ids to this key
Use SADD entity1:ids 1
to add and SMEMBERS
and SUNION
to retrieve all the ids for one entity or the union of multiple entities, doc here.