Skip to content

Instantly share code, notes, and snippets.

@nemo83
nemo83 / gist:fcc36fe785ec831cf62e35aa04e7ce55
Last active April 18, 2017 09:24 — forked from klovadis/gist:5170446
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk = redis.call('HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
result[nextkey] = v