ioredis (nodejs):使用 lua 脚本调试自定义命令

ioredis (nodejs): Debugging custom command with lua script

我写了一个自定义的 lua 脚本,这样我就可以在我的节点进程中 ioredis 运行 它:

REDIS_CLIENT.defineCommand('my_command', {
            lua: fs.readFileSync(path.resolve(__dirname, './lua_scripts/my_command.lua'), {
                encoding: 'utf8'
            })
        });

我想在我的 my_commands.lua 中添加打印,所以当我 运行 client.my_command(args) 它将被打印到 nodejs 进程 stdout 但是当我添加 print "hello lua" 它没有(这是有道理的)。

有没有办法将 lua 自定义脚本中的内容打印到我的 nodejs 进程标准输出中?

没有直接的方法,但我描述了一些间接的方法 here. Out of these, excluding the new v3.2 integrated Lua debugger and the Zerobrane Studio plugin,跟踪 IMO 最有用和最简单的方法是使用 PubSub 或 ECHO & MONITOR.