lua语言中如何获得redis订阅的message?
天蓬老师
天蓬老师 2017-04-21 11:19:08
0
1
776

最开始是使用云风的skynet框架连接redis然后执行命令,但是db:subscribe(pattern)后不知道怎么获取后续的订阅消息。Python是有listen()这样的函数,但是lua中好像没能找到……
如果实在不行地话只能用Lua调用python脚本了,不过完全不知道怎么用lua调用python= =

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
大家讲道理

Another self-question and answer...I got the answer in Yunda's google group. This is what is written in skynet.

local function watching()
    local w = redis.watch(conf)
    w:subscribe "foo"
    w:psubscribe "hello.*"
    while true do
        print("Watch", w:message())
    end
end

How does skynet’s redis interface receive subsequent subscription messages from subscribe?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template