I have an activity feed system that uses Redis sorted sets.
Events occur, and the message is placed in a sorted set for each relevant user with a time stamp for evaluation.
Messages are then distributed to users either at logon or via push if the user is currently logged in.
I would like to distinguish between messages that have been "read" by the user, and those that have not yet been read.
In my opinion, I can’t just have the read / read property as part of the member, since changing it will cause the member to be different, and therefore will be added a second time instead of replacing the current member.
So, I think that for each user I have to sort the set - the “unread” set and the “read” set.
- When new events appear, they are added to the “unread” set
- When a user reads a message, I add the message to the reading set and remove it from the unread set.
A little less sure about how to deliver them. I can’t just combine them, because I lose the distinction between reading / unread if I don’t pay the bill to unread, for example.
Returning two sets separately (and combining them into code) makes swapping difficult. I would like the 20 most recent posts to be independent of read / unread status.
So the questions are:
- Is a read set / unread way the best way to do this? Is there a better way?
- What is the best way to return a subset of the data of a combined /union.d.
Thanks!
source share