redisMonitorChannels(rredis)
redisMonitorChannels()所属R语言包:rredis
redisMonitorChannels
redisMonitorChannels
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Subscribe to one or more Redis message channels.
订阅一个或多个Redis的消息信道。
用法----------Usage----------
redisMonitorChannels()
Details
详细信息----------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.
(从Redis.io文档):redisSubscribe,redisUnsubscribe和redisPublish实施(引自维基百科)发送者(出版社)编程来发送他们的消息发布/订阅消息传递模式具体的接收器(用户)。相反,不同渠道发布的消息,没有什么(如果有的话)用户可能存在的知识。用户表示有兴趣在一个或多个通道,只接受有兴趣的消息,没有什么(如果有的话)的出版商有知识。
The redisMonitorChannels function may be called repeatedly in an event loop to service messages on all subscribed channels. When a message is received, the redisMonitorChannels function will attempt to evaluate a callback function with same name as the channel, with the message as its single argument. If no such function can be found, the message is returned. See the help page for redisGetResponse for a description of the message format.
在事件反复循环,以服务所有订阅的频道消息redisMonitorChannels可能会被调用。当一个消息被接收,redisMonitorChannels函数将试图评估一个回调函数具有相同名称的通道,作为其唯一的参数消息。如果没有这样的功能可以发现,该消息被返回。请参阅帮助页面redisGetResponse的消息格式的描述。
WARNING: The redisMonitorChannels function blocks indefinitely until a message is received.
警告:redisMonitorChannels的功能块下去,直到收到一条消息。
Use the lower-level redisGetResponse function to simply poll channels for messages without evaluating function callbacks.
使用较低级别的redisGetResponse功能,简单的轮询消息的渠道,而不计算回调函数。
值----------Value----------
The result of an evaluated function callback message, or if
结果评估的回调函数消息,或者如果
(作者)----------Author(s)----------
B. W. Lewis
参考文献----------References----------
参见----------See Also----------
redisSubscribe redisPublish redisUnsubscribe redisGetResponse redisMonitorChannels
redisSubscriberedisPublishredisUnsubscriberedisGetResponseredisMonitorChannels
实例----------Examples----------
## Not run: [#不运行:]
redisConnect()
# Define a callback function to process messages from channel 1:[定义一个回调函数来处理来自通道1的消息:]
channel1 <- function(x) {
cat("Message received from channel 1: ",x,"\n")
}
# Define a callback function to process messages from channel 2:[定义一个回调函数来处理来自通道2的消息:]
channel2 <- function(x) {
cat("Message received from channel 2: ",x,"\n")
}
redisSubscribe(c('channel1','channel2'))
# Monitor channels for at least 1 minute:[监测至少1分钟的渠道:]
t1 <- proc.time()[[3]]
while(proc.time()[[3]] - t1 < 60)
{
redisMonitorChannels()
Sys.sleep(0.05)
}
redisUnsubscribe(c('channel1','channel2'))
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|