Created
October 21, 2012 22:49
-
-
Save mrkvm/3928815 to your computer and use it in GitHub Desktop.
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
-- Set a key containing JSON in Redis | |
local key = KEYS[1]; | |
local name = ARGV[1]; | |
local value = ARGV[2]; | |
local data = redis.call('GET', key); | |
local json; | |
if not data then | |
json = {}; | |
else | |
json = cjson.decode(data); | |
end | |
json[name] = value; | |
redis.call('SET', key, cjson.encode(json)); | |
return cjson.encode(json); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment