Redis-pub-sub-psubscribe

提供:Dev Guides
移動先:案内検索

Redis-PubSub Psubscribeコマンド

Redis PSUBSCRIBE コマンドは、特定のパターンに一致するチャネルをサブスクライブするために使用されます。

構文

以下は、Redis PSUBSCRIBE コマンドの基本的な構文です。

redis 127.0.0.1:6379> PSUBSCRIBE CHANNEL_NAME_OR_PATTERN [PATTERN...]

次のリストは、Redisでサポートされているいくつかのパターンを示しています。

  • h?lloは、hello、hallo、およびhxlloをサブスクライブします。 h lloはhlloとheeeelloを購読しています
  • h [ae] lloはhelloとhalloをサブスクライブしますが、hilloはサブスクライブしません

redis 127.0.0.1:6379> PSUBSCRIBE mychannel
Reading messages... (press Ctrl-C to quit)
1) "psubscribe"
2) "mychannel"
3) (integer) 1