1

我检查了 Redis 发布/订阅功能,乍一看,它看起来非常适合形成 twitter 提要之类的东西。但是,我尝试在 Google 上搜索 Redis pub/sub 和 newsfeed,但我几乎找不到任何关于此的示例或用例。如果 Redis 实际上对此并不擅长,那么它的缺点是什么?

4

1 回答 1

2

First of all, Redis pub/sub is not a data storage, but just a data flow channel.

For example(Chronologically sequenced)

  1. You create a channel named news:feed
  2. User A joins news:feed
  3. User B publishes to news:feed

This scenario works fine. But the following doesn't:

  1. You create a channel named news:feed
  2. User B publishes to news:feed
  3. User A joins news:feed

In this case, user A will never receive the message published by User B, before he (A) joined.

If you want to implement newsfeed using pub/sub, you have to create several channels (at least as many as users). Here is an implementation of a simple Twitter clone: http://redis.io/topics/twitter-clone

于 2013-11-12T05:26:33.530 回答