suchen

Heim  >  Fragen und Antworten  >  Hauptteil

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

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

天蓬老师天蓬老师2886 Tage vor811

Antworte allen(1)Ich werde antworten

  • 大家讲道理

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

    又一次自问自答……在云大的google group里获得了答案。在skynet里是这么写的。

    1

    2

    3

    4

    5

    6

    7

    8

    9

    <code>local function watching()

        local w = redis.watch(conf)

        w:subscribe "foo"

        w:psubscribe "hello.*"

        while true do

            print("Watch", w:message())

        end

    end

    </code>

    skynet的redis接口如何接收subscribe后续传来的订阅消息?

    Antwort
    0
  • StornierenAntwort