Latest web development tutorials

Redis Psubscribe 命令

Redis發布訂閱

Redis Psubscribe 命令訂閱一個或多個符合給定模式的頻道。

每個模式以* 作為匹配符,比如it* 匹配所有以it 開頭的頻道( it.news 、 it.blog 、 it.tweets 等等)。 news.* 匹配所有以news. 開頭的頻道( news.it 、 news.global.today 等等),諸如此類。

語法

redis Psubscribe 命令基本語法如下:

redis 127.0.0.1:6379> PSUBSCRIBE pattern [pattern ...]

可用版本

>= 2.0.0

返回值

接收到的信息。

實例

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

Redis發布訂閱