本文共 748 字,大约阅读时间需要 2 分钟。
redis发布/订阅广播
Redis implements a publish/subscribe messaging mechanism.
Redis实现了发布/订阅消息传递机制。
Its concept is simple: a publisher sends a message on a channel. Multiple subscribers receive it.
它的概念很简单:发布者在频道上发送消息。 多个订户收到它。
Subscribe to a channel using
订阅频道使用
SUBSCRIBE
Publish to a channel using
使用发布到频道
PUBLISH
Example:
例:
SUBSCRIBE dogs
In another redis-cli
window, type:
在另一个redis-cli
窗口中,输入:
PUBLISH dogs "Roger"
Messages will be sent to the subscribers, and they’ll by default display the kind of event, the channel, and the message:
消息将发送给订阅者,默认情况下,它们将显示事件的种类,频道和消息:
Subscribers can listen on multiple channels:
订户可以在多个频道上收听:
SUBSCRIBE dogs cats
and will receive messages coming from all of them.
并会收到来自所有人的消息。
翻译自:
redis发布/订阅广播
转载地址:http://pxmgb.baihongyu.com/