Last active
April 19, 2017 20:55
-
-
Save fritzy/7376653 to your computer and use it in GitHub Desktop.
Collate a Hash in Redis
This file contains 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
--EVAL "this script" 1 some-hash-key | |
local key = KEYS[1]; | |
local keyvalues = redis.call('HGETALL', key); | |
local result = {}; | |
--every other value is a key | |
for idx = 1, #keyvalues, 2 do | |
result[keyvalues[idx]] = keyvalues[idx + 1] | |
end | |
return cjson.encode(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment