Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Psubscribe Command

Redis Psubscribe Command

Redis Publish/Subscribe

The Redis Psubscribe command subscribes to one or more channels matching the given pattern.

Each pattern uses * as a wildcard. For example, it* matches all channels starting with it (it.news, it.blog, it.tweets, etc.). news.* matches all channels starting with news. (news.it, news.global.today, etc.), and so on.

Syntax

The basic syntax of the redis Psubscribe command is as follows:



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

Available Version

= 2.0.0

Return Value

The received message.

Example



redis 127.0.0.1:6379> PSUBSCRIBE mychannel

Reading messages... (press Ctrl-C to quit)

1) "psubscribe"

2) "mychannel"

3) (integer) 1

Redis Publish/Subscribe