Delete Sorted Set Item

25 views
Skip to first unread message

Cameron Barker

unread,
Jan 9, 2013, 4:55:28 PM1/9/13
to redi...@googlegroups.com
Hi all,

Working on a social feed using redis which when a user posts will push out to all their followers feed.  This is all happening in sorted sets with creation time as the score.  I'm working on when the user deletes a post at the moment.  I understand that when my user deletes the post that I'll just cycle through the friends looking if the value is in their feed and if so delete it.  

My question is what happens if a user posts something, one of their followers unfollows them, then the user deletes the post, there will be no record of that past follower so it will be skipped in the deletion process outlined above.

Is there a simple logic to solve this problem?  Or because feeds are usually short lived and this a semi-rare situation do we just leave the post on the feed?

Thank you!!

Josiah Carlson

unread,
Jan 10, 2013, 12:42:20 AM1/10/13
to redi...@googlegroups.com
When you fetch the post information, among other pieces of data you
have will be the user id of the original posting user. With this
information, you can then perform a pipelined sequence of ZSCORE
operations against your friends ZSET. If you want to reduce data
transfer a bit, you could also execute a Lua script that does the same
thing (checking ZSCOREs), or even write a Lua script that does the
entire fetch, including checking for friends ZSET membership.

Regards,
- Josiah
> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/redis-db/-/NinkI9mb6LYJ.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to
> redis-db+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/redis-db?hl=en.

Colin Vipurs

unread,
Jan 10, 2013, 9:02:00 AM1/10/13
to redi...@googlegroups.com
This is pretty much what we do (except we don't use redis for our social data).

With regards to the OP I'm not sure I'd even bother delete from your
followers feeds and just filter on the way out. Depending on how
active your friends are, filtering out people who are no longer in
your friends graph should be a relatively rare occurrence.
--
Maybe she awoke to see the roommate's boyfriend swinging from the
chandelier wearing a boar's head.

Something which you, I, and everyone else would call "Tuesday", of course.
Reply all
Reply to author
Forward
0 new messages