redisSubscribe(rredis)
redisSubscribe()所属R语言包:rredis
redisSubscribe
redisSubscribe
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Subscribe to one or more Redis message channels.
订阅一个或多个Redis的消息信道。
用法----------Usage----------
redisSubscribe(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.
如果是TRUE,允许在通道名称的通配符模式匹配,否则的名称表示充分的频道的名称。
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实施(引自维基百科)发送者(出版社)编程来发送他们的消息发布/订阅消息传递模式具体的接收器(用户)。相反,不同渠道发布的消息,没有什么(如果有的话)用户可能存在的知识。用户表示有兴趣在一个或多个通道,只接受有兴趣的消息,没有什么(如果有的话)的出版商有知识。
Use the Redis function redisUnsubscribe to unsubscribe from one or more channels. Service incoming messanges on the channels with either redisGetResponse or redisMonitorChannels.
使用Redis的功能redisUnsubscribe退订从一个或多个通道。的渠道是redisGetResponse或redisMonitorChannels的传入messanges服务。
Use of any other Redis after redisSubscribe prior to calling redisUnsubscribe will result in an error.
使用Redis的任何其他后redisSubscribe之前调用redisUnsubscribe将导致错误。
值----------Value----------
A list conforming to the Redis subscribe response message. Each subscribed channel corresponds to three list elements, the header 'subscribe' followed by the channel name and a count indicating the total
符合的Redis的列表订阅响应消息。每个订阅的通道对应头“订阅”三个列表中的元素,其次是频道的名称和计数的总
(作者)----------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:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|