RedisJSON / RedisJSON2

Rust based RedisJSON implementation - Deprecated and moved to RedisJSON/RedisJSON
https://redisjson.io
Other
54 stars 4 forks source link
json redis redis-module redisjson

This repository was deprecated and all future development was moved to https://github.com/RedisJSON/RedisJSON

GitHub issues CircleCI Docker Cloud Build Status Mailing List Gitter

RedisJSON2

RedisJSON2 (RedisJSON nextgen) is a Redis module that implements ECMA-404 The JSON Data Interchange Standard as a native data type. It allows storing, updating and fetching JSON values from Redis keys (documents).

Primary features:

Quick start

docker run -p 6379:6379 --name redis-redisjson redislabs/redisjson2:latest

New Commands in RedisJSON2

JSON.INDEX ADD <index> <field> <path>
JSON.QGET <index> <query> <path>

Next Milestone

JSON.QSET <index> <query> <path> <json> [NX | XX]
JSON.QDEL <index> <query> <path>

JSON.INDEX DEL <index> <field>
JSON.INDEX INFO <index> <field>

Return value from JSON.QGET is an array of keys and values:

key
json
key
json

In a language such as Java this could be represented as a Map<String, Document>.

Examples

A query combining multiple paths:

JSON.QGET mytype "@path1:hello @path2:world" d.name
127.0.0.1:6379> json.set user1 $ '{"last":"Joe", "first":"Mc"}' INDEX person
OK
127.0.0.1:6379> json.set user2 $ '{"last":"Joan", "first":"Mc"}' INDEX person
OK
127.0.0.1:6379> json.index add person last $.last
OK
127.0.0.1:6379> JSON.QGET person Jo*
"{\"user2\":[{\"last\":\"Joan\",\"first\":\"Mc\"}],\"user1\":[{\"last\":\"Joe\",\"first\":\"Mc\"}]}"
127.0.0.1:6379> json.set user3 $ '{"last":"Joel", "first":"Dan"}' INDEX person
OK
127.0.0.1:6379> JSON.QGET person Jo*
"{\"user2\":[{\"last\":\"Joan\",\"first\":\"Mc\"}],\"user1\":[{\"last\":\"Joe\",\"first\":\"Mc\"}],\"user3\":[{\"last\":\"Joel\",\"first\":\"Dan\"}]}"
127.0.0.1:6379> json.index add person first $.first
OK
127.0.0.1:6379> JSON.QGET person Mc
"{\"user2\":[{\"last\":\"Joan\",\"first\":\"Mc\"}],\"user1\":[{\"last\":\"Joe\",\"first\":\"Mc\"}]}"
127.0.0.1:6379> JSON.QGET person Mc $.last
"{\"user2\":[\"Joan\"],\"user1\":[\"Joe\"]}"

Build

cargo build --release

Run

Linux

redis-server --loadmodule ./target/release/libredisjson.so

Mac OS

redis-server --loadmodule ./target/release/libredisjson.dylib