I have thousands of messages stored in a separate key like a list of properties (text, topic, date, etc.): < Code> Message: 1001 , msg: 1002
etc ...
There is also a list with ID as message
all Existing message: 1001,1002,1003 ...
Now I need to get 10 random messages.
However, I only need those messages flagged not by user (unread of type).
Flags: USERID
= 1001 does not have a hash for each user = red, 1005 = blue, 1010 = red, ...
Currently I will have to keep a complete list of messages and all the flags for all the logged users currently in memory of my application
Is such a question Redis is way to do, with no duplicating of all data on the end of the application?
Your question is an example of one. On the one hand, you say that you do not want to keep a list of unrelated messages in your system, but I guess you want to keep your application relatively fast. Therefore, I suggest leaving some space and keep the set of messages without any.
As messages are created in your system, add them both to messages
() and messages_unflagged
() to a user in a message After the flag has been added, remove the message from the Unflags Set () when you need 10 random, unplugged messages, you can get their ID in constant time ().
Comments
Post a Comment