Redis - 釋出訂閱 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 
redis_pub_sub.htm
廣告
© . All rights reserved.