Redis(7):メッセージの購読と公開
購読する
購読者1:
サブスクライバ2:
パイプ1にメッセージを発行するには、次の手順に従います.
サブスクリプション1とサブスクリプション2にメッセージが表示されます.
購読者1:
127.0.0.1:6379> SUBSCRIBE channel1 chanle2
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "channel1"
3) (integer) 1
1) "subscribe"
2) "chanle2"
3) (integer) 2
サブスクライバ2:
127.0.0.1:6379> SUBSCRIBE channel1
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "channel1"
3) (integer) 1
パイプ1にメッセージを発行するには、次の手順に従います.
127.0.0.1:6379> PUBLISH channel1 "this is a msg"
(integer) 2
# 2 2
サブスクリプション1とサブスクリプション2にメッセージが表示されます.
1) "message"
2) "channel1"
3) "this is a msg"