Skip to content

Instantly share code, notes, and snippets.

@slattery
Forked from fritzy/getmsgpackasjson.lua
Created March 5, 2014 20:21

Revisions

  1. @fritzy fritzy created this gist Nov 6, 2013.
    5 changes: 5 additions & 0 deletions getmsgpackasjson.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    --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;
    5 changes: 5 additions & 0 deletions setjsonasmsgpack.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    --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);