Created
March 15, 2013 14:51
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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