I need to use Redis HMGET
from a Lua script and extract specific values in following code.
But redis.call(\'HMGET\', table_key, hkey1, hkey2, ...)
After some profiling and tests, we found the following function to have good performance and use it to get a proper table.
This save the need to call a getter function for each hash key retrieval.
local function hgetall(hash_key)
local flat_map = redis.call('HGETALL', hash_key)
local result = {}
for i = 1, #flat_map, 2 do
result[flat_map[i]] = flat_map[i + 1]
end
return result
end