-
-
Save paggiogriot/2b25e4067abe6deeec716abaebee6a4f 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 hidden or 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 hidden or 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