无涯教程-Redis - PSUBSCRIBE 命令函数

45 阅读1分钟

Redis PSUBSCRIBE 命令用于订阅与给定模式匹配的频道。

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"和"你好",但不订阅" hillo"

PSUBSCRIBE - 示例

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

参考链接

www.learnfk.com/redis/pub-s…