Nov 24, 2020 Docker takes the same kind of version control and packaging that tools like Git and NPM provide and allows you to use it for your server software. Since your container is a single image, it makes it very easy to version track different builds of your container. And since everything is contained, it makes managing all of your dependencies much. So instead of typing out heroku container., once you npm i -g docker-up you can just do docker-up or docker-up -update to push a new version on the same appname, rather than heroku create a.
RedisJSON 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:
- Full support of the JSON standard
- JSONPath -like syntax for selecting elements inside documents
- Documents are stored as binary data in a tree structure, allowing fast access to sub-elements
- Typed atomic operations for all JSON values types
RedisJSON is developed with <3 at Redis Labs . The source code is availableat: https://github.com/RedisJSON/RedisJSON
Quickstart ¶
- Use it from any Redis client , e.g.:
Alternatively, you can also build and load the module yourself. Build and Load the RedisJSON module library
Redis Cloud ¶
RedisJSON is available on all Redis Cloud managed services. Redis Cloud Essentials offers a completely free managed databbases up to 30MB.
Launch RedisJSON with Docker ¶
Run the following on Windows, MacOS or Linux with Docker.
Using RedisJSON ¶
Before using RedisJSON, you should familiarize yourself with its commands and syntax as detailed in the commands reference document. However, to quickly get started just review this section and get:
- A Redis server running the module (see building and loading for instructions)
- Any Redis or RedisJSON client
With redis-cli
¶
This example will use redis-cli
as the Redis client. The first RedisJSON command to try out is JSON.SET
, which sets a Redis key with a JSON value. All JSON values can be used, for example a string:
JSON.GET
and JSON.TYPE
do literally that regardless of the value's type, but you should really check out JSON.GET
prettifying powers. Note how the commands are given the period character, i.e. .
. This is the path to the value in the RedisJSON data type (in this case it just means the root). A couple more string operations:
JSON.STRLEN
tells you the length of the string, and you can append another string to it with JSON.STRAPPEND
. Numbers can be incremented and multiplied :
Of course, a more interesting example would involve an array or maybe an object:
The handy JSON.DEL
command deletes anything you tell it to. Arrays can be manipulated with a dedicated subset of RedisJSON commands:
And objects have their own commands too:
With any other client ¶
Unless your Redis client already supports Redis modules (unlikely) or RedisJSON specifically (even more unlikely), you should be okay using its ability to send raw Redis commands. Depending on your client of choice, the exact method for doing that may vary.
Python example ¶
This code snippet shows how to use RedisJSON with raw Redis commands from Python with redis-py :
Download and running binaries ¶
First download the pre-compiled version from RedisLabs download center .
Next, run Redis with RedisJSON:
Building and Loading the Module ¶
Linux Ubuntu 16.04 ¶
Requirements:
- The RedisJSON repository:
git clone https://github.com/RedisJSON/RedisJSON.git
- The
build-essential
package:apt-get install build-essential
To build the module, run make
in the project's directory.
Congratulations! You can find the compiled module library at src/rejson.so
.
MacOSX ¶
To build the module, run make
in the project's directory.
Congratulations! You can find the compiled module library at src/rejson.so
.
Loading the module to Redis ¶
Requirements:
We recommend you have Redis load the module during startup by adding the following to your redis.conf
file:
In the line above replace /path/to/module/rejson.so
with the actual path to the module's library. Alternatively, you can have Redis load the module using the following command line argument syntax:
Lastly, you can also use the MODULE LOAD
command. Note, however, that MODULE LOAD
is a dangerous command and may be blocked/deprecated in the future due to security considerations.
Once the module has been loaded successfully, the Redis log should have lines similar to:
Client libraries ¶
Docker Npm Build
Some languages have client libraries that provide support for RedisJSON's commands:
Docker Npm Install Not Working
Project | Language | License | Author | Stars | Package |
---|---|---|---|---|---|
iorejson | Node.js | MIT | Evan Huang @evanhuang8 | npm | |
node_redis-rejson | Node.js | MIT | Kyle Davis @stockholmux | npm | |
redis-modules-sdk | Node.js | BSD-3-Clause | Dani Tseitlin @danitseitlin | npm | |
JRedisJSON | Java | BSD-2-Clause | Redis Labs | maven | |
redisjson-py | Python | BSD-2-Clause | Redis Labs | pypi | |
go-rejson | Go | MIT | Nitish Malhotra @nitishm | ||
rejonson | Go | Apache-2.0 | Daniel Krom @KromDaniel | ||
NReJSON | .NET | MIT/Apache-2.0 | Tommy Hanks @tombatron | nuget | |
phpredis-json | PHP | MIT | Rafa Campoy @averias | composer | |
redislabs-rejson | PHP | MIT | Mehmet Korkmaz @mkorkmaz | composer | |
rejson-rb | Ruby | MIT | Pavan Vachhani @vachhanihpavan | rubygems |