common.lua 332 B

123456789101112131415
  1. -- gets all fields from a hash as a dictionary
  2. local hgetall = function (key)
  3. local bulk = redis.call('HGETALL', key)
  4. local result = {}
  5. local nextkey
  6. for i, v in ipairs(bulk) do
  7. if i % 2 == 1 then
  8. nextkey = v
  9. else
  10. result[nextkey] = v
  11. end
  12. end
  13. return result
  14. end