Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8044367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:12:33+00:00 2026-06-05T05:12:33+00:00

Suppose we are duplicating the Twitter’s follow function. As far as I can tell,

  • 0

Suppose we are duplicating the Twitter’s follow function. As far as I can tell, everyone now agrees to the following design using Redis.

All tweets followed by joe are stored in a sorted set “ss:joe” with key=tweet_id, score=tweet_timestamp

So when joe follows ladygaga, ladygaga’s tweets are added to “ss:joe”, so far so good.

The question is: how do I remove ladygaga’s tweets from “ss:joe” when joe unfollows ladygaga?

Iterating through every single “ss:joe” tweet and remove those that belong to ladygaga is out.

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”.

Is there a better solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:12:34+00:00Added an answer on June 5, 2026 at 5:12 am

    There is an even bigger problem to this design. Storing the tweet_ids in ss:joe means that the system cannot account for gaga creating a new tweet (or deleting one, if that is supported) without also modifying ss:joe. Now imagine having a few hundred celebs with 50,000 followers each, and each writing a dozen tweets per day. That’s a lot of inserts into a lot of sets, which you cannot easily distribute either. And, it’s a lot of duplicate data (remember redis is a RAM-only database, and although RAM gets cheaper it’s still nowhere near “unlimited”). EDIT: And for updating follower records, you need to know the followers too (since iterating over every user on every newly written tweet is hardly an option). So you need to maintain a list of backlinks as well.

    An alternative design would be to store the user ID of the followed person in a set (or sorted set, if you will, so the user can shuffle the order). Each person further has a sorted set with all their tweet IDs (sorted by date).

    This will require an additional query per followed person to get the tweet IDs, but it will reduce unfollowing to removing one value from a set, and it will keep everyone updated automatically as new tweets are created.

    Lookups are less costly than inserts/removes (which may require rebalancing or rehashing), so even if you follow a dozen people, those extra queries probably aren’t as much of an issue as would be more frequent updates.
    Plus, lookups can actually happen on a network of replicated slaves (a second or two may pass before a new tweet is visible to everyone, but who cares — it scales infinitely).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose we have the following table data: ID parent stage submitted 1 1 1
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input
Suppose we have the following: data Foo x from_list :: [x] -> Foo x
Suppose I have the following table: PERSON : ID INT NAME STRING LASTNAME STRING
Suppose i have a cookie set in first.com say user. Now i want to
Is there a reason why I can use a generic function with different type
Suppose that you have the following hierarchy of statistics-related classes, structured in a manner
I'm implementing an API. The API accepts/returns JSON content type. Now, suppose that the
Suppose I created index with descending order CREATE INDEX `MyTable.MyIndex` USING BTREE ON `MyTable`
I want to avoid code duplication as much as possible. Suppose I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.