I am using nekipelov/redisclient to access Redis and I need to retrieve multiple hash data with one call to Redis to increase performance.
More specific, I am trying to retrieve multiple hashes like below:
redis-cli --ldb --eval /tmp/script.lua hash_key1 hash_key2
where script.lua:
local r = {}
for _, v in pairs(KEYS) do
r[#r+1] = redis.call('HGETALL', v)
end
return r
But I have difficulty to express the above by using EVAL command through nekipelov/redisclient.
I tried something below:
redisclient.command("EVAL", {"/tmp/script.lua", hash_key1, hash_key2}
but obviously is wrong.
I found the solution and the problem appeared on how I constructed the EVAL command in redisclient - I was passing the Lua script as a file: