Skip to content
Golang Redis Rejson extension built upon go-redis
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Redis rejson extension built upon go-redis

Build Status Coverage Status

Table of Contents

  1. Quick start
  2. API
  3. Dependencies
  4. Testing
  5. License
  6. Contact

Quick start


go get


import ""

The examples are using jonson library which is optional (but recommended)

Extend Client

We extend a client to add it all the rejson abilities, extended client will have all the go-redis functionality with all the rejson functionality.
Extended client is very comfortable to use because we don't need to pass a connection each time to some static method that accepts connection + args but instead just use the connection directly

goRedisClient := redis.NewClient(&redis.Options{
    Addr:     "localhost:6379",
    Password: "",
    DB:       0,
client := rejonson.ExtendClient(goRedisClient)
defer client.Close()

// client got all go-redis commands with 
json := jonson.New([]interface{}{"hello", "world", "rejson", "and", "rejonson", "are", "awesome", 1,2,3,4})
client.Set("go-redis-command", "hello", time.Second)
client.JsonSet("rejonson-json-command", ".", json.ToUnsafeJSONString())

arrLen, err := client.JsonArrLen("rejonson-json-command", ".").Result() // int command
if err != nil {
    // handle the error

fmt.Println("The array length is",  arrLen) // The array length is 11


Client will also return extended Pipeline and TXPipeline

pipeline := client.Pipeline()
pipeline.JsonNumMultBy("rejonson-json-command", "[7]", 10) // same array from the first example
pipeline.Set("go-redis-pipeline-command", "hello from go-redis", time.Second)

_, err = pipeline.Exec()
if err != nil {
    // handle error
jsonString, err := client.JsonGet("rejonson-json-command").Result()
if err != nil {
    // handle error
json = jonson.ParseUnsafe([]byte(jsonString))

fmt.Println(json.At(7).GetUnsafeFloat64()) // 10


Rejonson supports all the methods as described at ReJson Commands except for JSON.DEBUG and JSON.RESP. The arguments will be transferred to redis so please make sure you conform the rejson documentation.

Due to some rejson behavior #issue-76, empty strings will be ignored

All the rejson methods starts with the prefix of Json e.g JsonDel, JsonArrIndex, JsonMGet.
Each command returns specific go-redis.Cmder by the specific request.


Rejonson got only single dependency which is go-redis. The testing got some other dependencies as well


It is recommended to run the unit tests when using rejonson.
The unit tests will make sure your go-redis version is compatible and your rejson plugin supports all the methods and working as expected.

The testing got few dependencies of its' own:

Configuring Redis

In order to guarantee the code is safe for use The unit tests will have to use a real redis. To configure the connection edit the file test_config.json

redisConnection will just be passed to go-redis.Options, the keys should conform with the Options keys.
redisKeyPrefix is the prefix the unit tests will add to written test data at the redis (the data is deleted at the end of each test)

  "redisConnection": {
    "Addr":  "localhost:6379",
    "Password": "",
    "DB": 0
  "redisKeyPrefix": "rejonson::tests::"


Apache 2.0


For any question or contribution, feel free to contact me at or open an issue.

You can’t perform that action at this time.