subscribe
UK[səbˈskraɪb] US[səbˈskraɪb]
vt.& vi. Subscription; pledge, donation; signature, inscription, signature; subscription, Order
Third person singular: subscribes Present participle: subscribing Past tense: subscribed Past participle: subscribed
redis PSUBSCRIBE command syntax
Function:Subscribe to one or more channels that match the given pattern.
Syntax:PSUBSCRIBE pattern [pattern ...]
Description:Each pattern uses * as the matching character, for example, it* matches all Channels that start with it ( it.news , it.blog , it.tweets , etc.), news.* matches all channels that start with news. ( news.it , news.global.today , etc.), and so on.
Available versions:>= 2.0.0
Time complexity:O(N), N is the number of subscribed patterns.
Returns:The information received (see code description below).
redis PSUBSCRIBE command example
# 订阅 news.* 和 tweet.* 两个模式 # 第 1 - 6 行是执行 psubscribe 之后的反馈信息 # 第 7 - 10 才是接收到的第一条信息 # 第 11 - 14 是第二条 # 以此类推。。。 redis> psubscribe news.* tweet.* Reading messages... (press Ctrl-C to quit) 1) "psubscribe" # 返回值的类型:显示订阅成功 2) "news.*" # 订阅的模式 3) (integer) 1 # 目前已订阅的模式的数量 1) "psubscribe" 2) "tweet.*" 3) (integer) 2 1) "pmessage" # 返回值的类型:信息 2) "news.*" # 信息匹配的模式 3) "news.it" # 信息本身的目标频道 4) "Google buy Motorola" # 信息的内容 1) "pmessage" 2) "tweet.*" 3) "tweet.huangz" 4) "hello" 1) "pmessage" 2) "tweet.*" 3) "tweet.joe" 4) "@huangz morning" 1) "pmessage" 2) "news.*" 3) "news.life" 4) "An apple a day, keep doctors away"