Thursday, 27 April 2017

Node running Lua script for Redis. How to return sorted set from Lua script to Node?

This is the Lua script code in file test.lua:

local ips_key = 'production:ips'
local ids = redis.call('ZRANGE', ips_key, 0, '+inf', 'WITHSCORES')
local result = {}
for i, name in ipairs(ids) do
    table.insert(result, name)
end
return js.global:Array(table.unpack(result))

I'm using ioredis, which is a redis npm to eval this lua script. the return value is undefined. What am I doing wrong? Thank you!



via PythonNoobile

No comments:

Post a Comment