Created
November 6, 2013 17:35
-
-
Save fritzy/7340641 to your computer and use it in GitHub Desktop.
Redis scripts to set JSON in, store as MSGPack, and get JSON out.
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-key | |
local key = KEYS[1]; | |
local value = redis.call('GET', key); | |
local jvalue = cjson.encode(cmsgpack.unpack(value)); | |
return jvalue; |
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-key '{"some": "json"}' | |
local key = KEYS[1]; | |
local value = ARGV[1]; | |
local mvalue = cmsgpack.pack(cjson.decode(value)); | |
return redis.call('SET', key, mvalue); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SET
GET