通过关系存储频繁请求的键值数据的有效方法?

时间:2021-10-20 13:46:31

Let's say I'm building Twitter.

假设我正在建立Twitter。

One of the tasks is to track, which tweets are read by particular user and store this data on server. When user requests somebody's feed, server should return:

其中一项任务是跟踪特定用户读取的推文,并将此数据存储在服务器上。当用户请求某人的订阅源时,服务器应该返回:

[
  {
    id: 1,
    tweet: "Hey there!",
    isRead: false
  },
  {
    id: 2,
    tweet: "Here's my cat, look",
    isRead: true
  },
  {
    id: 2,
    tweet: "Blue or yellow? Thats the question",
    isRead: true
  },
  ...
]

Which is the most efficient way to store data for which tweets are read by which user, and retrieving this data when returning somebody's feed for particular user?

哪种方式是存储数据的最有效方式,哪些用户可以读取推文,并在为特定用户返回某人的订阅源时检索此数据?

Any ideas about data storing architecture are highly appreciated. My current stack is PostgreSQL for storing users and "tweets". Redis, MongoDB and neo4j are also used in the project, so available.

关于数据存储架构的任何想法都非常受欢迎。我目前的堆栈是PostgreSQL,用于存储用户和“推文”。 Redis,MongoDB和neo4j也在项目中使用,因此可用。

The first guess was to use Redis, like:

第一个猜测是使用Redis,如:

user_id: tweet_id
-----------------
user_id: tweet_id
-----------------
....

But I think, there may be better variants, more suitable for persistent data storage.

但我认为,可能有更好的变体,更适合持久数据存储。

Thank you in advance.

先谢谢你。

1 个解决方案

#1


0  

Have a look at this Twitter-clone that Redis' author, antirez (a.k.a Salvatore Sanfilippo), had made: http://redis.io/topics/twitter-clone

看看Redis的作者antirez(a.k.a Salvatore Sanfilippo)制作的Twitter克隆:http://redis.io/topics/twitter-clone

#1


0  

Have a look at this Twitter-clone that Redis' author, antirez (a.k.a Salvatore Sanfilippo), had made: http://redis.io/topics/twitter-clone

看看Redis的作者antirez(a.k.a Salvatore Sanfilippo)制作的Twitter克隆:http://redis.io/topics/twitter-clone