Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

redisUnsubscribe

redisUnsubscribe


Description

Subscribe to one or more Redis message channels.

Usage

redisUnsubscribe(channels, pattern=FALSE)

Arguments

channels

A character vector or list of channel names to subscribe to.

pattern

If TRUE, allow wildcard pattern matching in channel names, otherwise names indicate full channel names.

Details

(From the Redis.io documentation): redisSubscribe, redisUnsubscribe and redisPublish implement the Publish/Subscribe messaging paradigm where (citing Wikipedia) senders (publishers) are not programmed to send their messages to specific receivers (subscribers). Rather, published messages are characterized into channels, without knowledge of what (if any) subscribers there may be. Subscribers express interest in one or more channels, and only receive messages that are of interest, without knowledge of what (if any) publishers there are.

Use the Redis function redisUnsubscribe to unsubscribe from one or more channels. Service incoming messanges on the channels with either redisGetResponse or redisMonitorChannels.

Use of any other Redis after redisSubscribe prior to calling redisUnsubscribe will result in an error.

Value

A list conforming to the Redis subscribe response message. Each subscribed channel corresponds to three list elements, the header element 'unsubscribe' followed by the channel name and a count indicating the total number of subscriptions.

Author(s)

B. W. Lewis

References

http://redis.io/commands

See Also

Examples

## Not run: 
redisConnect()
# Define a callback function to process messages from channel 1:
channel1 <- function(x) {
  cat("Message received from channel 1: ",x,"\n")
}
# Define a callback function to process messages from channel 2:
channel2 <- function(x) {
  cat("Message received from channel 2: ",x,"\n")
}
redisSubscribe(c('channel1','channel2'))
# Monitor channels for at least 1 minute:
t1 <- proc.time()[[3]]
while(proc.time()[[3]] - t1 < 60)
{
  redisMonitorChannels()
  Sys.sleep(0.05)
}
redisUnsubscribe(c('channel1','channel2'))

## End(Not run)

rredis

"Redis" Key/Value Database Client

v1.7.0
Apache License (>= 2.0)
Authors
B. W. Lewis
Initial release
2015-07-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.