Skip to content

Instantly share code, notes, and snippets.

@slattery
Forked from fritzy/getmsgpackasjson.lua
Created March 5, 2014 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slattery/9375774 to your computer and use it in GitHub Desktop.
Save slattery/9375774 to your computer and use it in GitHub Desktop.
--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;
--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