我正在传递一组键。这里keylist = ['KEY_100', 'KEY_101']
我想获取所有键值。但我在说这个错误:node_redis: Deprecated: The EVAL command contains a argument of type Array.
github中有一个问题,建议使用toString()并再次解析最后的值。但是我对此感到满意。谁能帮我解决这个问题?
Nodejs:
getDataLua (keylist) {
console.log('lua keylist:', keylist)
const getAsync = promisify(this.client.eval).bind(this.client)
const reply = await getAsync(fs.readFileSync('./lib/test1.lua'), 1, keylist)
console.log('reply', reply)
return reply
}
Lua脚本:
local keys = redis.call('keys', KEYS[1])
local values = redis.call('mget', unpack(keys))
local keyValuePairs = {}
for i = 1, #keys do
keyValuePairs[i] = .. values[i]
end
return keyValuePairs
您应该做这样的事情:
const reply = await getAsync(fs.readFileSync('./lib/test1.lua'), keylist.length, ...keylist);