JSON with Redis server-side Lua
This is an implementation of ReJSON's
JSON.GET commands in pure Redis Lua. The
data is stored using Redis' native String data structure.
Yep, that's right, no modules needed.
The implementation consists of two variants: one uses JSON format for storing the data, while the other stores it in MessagePack format.
This variant stores the data in JSON format. It uses (when required) the built-in
cjson library for decoding/encoding from/to JSON to/from
Lua's native table data type. It is made of the following scripts:
json-set-root.luasets the root to a JSON value. Because this variant stores serialized JSON format, this just calls Redis'
json-get-root.luagets the JSON value at the root. Similarly, this just calls Redis'
GETcommand to return the serialized JSON value.
json-set-path.luasets the value at a path. To perform the update, the serialized JSON value is decoded, updated and then rendcoded as JSON before being stored.
json-get-path.luagets the value from a path. To perform the read, the serialized JSON value is decoded and then the value at the path is rencoded as JSON before being returned.
These scripts use the
cmsgpack library to decode/encode
the value before/after storing/fetching it in/from Redis. All scripts in this variant are
functionally identical to their respective above counterparts but include the required conversions