Home  >  Q&A  >  body text

lua语言中如何获得redis订阅的message?

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

天蓬老师天蓬老师2709 days ago685

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-04-21 11:21:08

    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?

    reply
    0
  • Cancelreply