title: Redis Twitter-like Follow/Unfollow Design Pattern
body: <p>Suppose we are duplicating the Twitter's follow function. As far as I can tell, everyone now agrees to the following design using Redis.</p>
  
  <p>All tweets followed by joe are stored in a sorted set "ss:joe" with key=tweet_id, score=tweet_timestamp</p>
  
  <p>So when joe follows ladygaga, ladygaga's tweets are added to "ss:joe", so far so good.</p>
  
  <p>The question is: how do I remove ladygaga's tweets from "ss:joe" when joe unfollows ladygaga?</p>
  
  <p>Iterating through every single "ss:joe" tweet and remove those that belong to ladygaga is out.</p>
  
  <p>The best I can think of is to maintain another sorted set for every user storing her own tweets, so ladygaga will have her sorted set "tweets:ladygaga" with key=tweet_id, score=tweet_timestamp, then we can pick out ladygaga's tweets by ZINTERSTORE "ss:joe" and "tweets:ladygaga".</p>
  
  <p>Is there a better solution?</p>