Skip to content

Instantly share code, notes, and snippets.

@klovadis
Created March 15, 2013 14:51
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klovadis/5170386 to your computer and use it in GitHub Desktop.
Save klovadis/5170386 to your computer and use it in GitHub Desktop.
Lua script for redis to turn a dictionary table into a bulk reply
-- turns a dictionary table into a bulk reply table
local dict2bulk = function (dict)
local result = {}
for k, v in pairs(dict) do
table.insert(result, k)
table.insert(result, v)
end
return result
end
-- example
local mytable = { foo='bar', baz='asdf' }
mytable['abc'] = 'def'
-- turn that table into a bulk reply
return dict2bulk(mytable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment