redisGetResponse: redisGetResponse

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/controlCMD.R

Description

Service messages from all subscribed Redis message channels.

Usage

1

Arguments

all

The all argument is ignored. It's left there for backwards compatibility with code based on older package versions.

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.

The redisGetResponse function may be called to service messages on all subscribed channels. When a message is received the a list of three elements is returned containing: the character string 'message', the name of receiving channel, and the message content.

WARNING: The redisGetResponse function blocks indefinitely until a message is received.

Value

A list containing the string 'message', the channel name from which the message was received, and the message data.

Author(s)

B. W. Lewis

References

http://redis.io/commands

See Also

redisSubscribe redisPublish redisUnsubscribe redisMonitorChannels

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## 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 one minute (and indefinitely until
# a message is received):
t1 <- proc.time()[[3]]
while(proc.time()[[3]] - t1 < 60)
{
  print(redisGetResponse())
}
redisUnsubscribe(c('channel1','channel2'))

## End(Not run)

bwlewis/rredis documentation built on Jan. 3, 2022, 4:53 p.m.