Community Blog Getting up Your Real-Time Key-Value Store with RedixDB

Getting up Your Real-Time Key-Value Store with RedixDB

In this article, you will be learning how you can set up RedixDB on an Alibaba Cloud ECS instance as well as learn about some of the basic commands and features of RedixDB.

By Dassi Orleando, Alibaba Cloud Community Blog author.

RedixDB is an open-source and real-time key-value store that uses the same protocol as Redis along with several other additional features, including a fast non-relational database, which also uses the same RESP protocol and is capable of storing several terabytes of data. RedixDB integrates several real-time features through which it can serve as a document store, making it a multi-model database.

In this article, we'll cover how you can install and set up RedixDB on an Alibaba Cloud Elastic Compute Service (ECS) instance. Next, in this article, we will also cover some basic commands and how you can use and take advantage of some of the major features of RedixDB.

Installing and Setting up Redix

As the first leg of this tutorial, we need to create an Alibaba Cloud ECS instance. For this tutorial, I'll be creating an ECS instance with just the basic configuration, being installed with Ubuntu and equipped with one-core processor and 512 MB memory. You can log on to your ECS instance using SSH or through the Alibaba Cloud console. For reference, you can check out this guide.

Next, now it comes to the fun part, installing Redix, which is relatively straightforward. We can quickly install it from binary. To get the corresponding binary to our operating system, we will need to access the releases page on GitHub and select the appropriate one depending on our platform.

At the time of writing this article the latest version is 1.8, which was released on the 02 January 2019, which we can pick up here by using the following command to get it on our remote machine:

wget https://github.com/alash3al/redix/releases/download/v1.8/redix_linux_amd64.zip 

Now we need to unzip the compressed file using the unzip package as follows: First, the command unzip redix_linux_amd64.zip is used to unzip it into the current directory. For a different destination we'll need to specify the –d option with a value, that is, the destination folder, either in a relative or absolute way. Next, we will have a redix_linux_amd64 executable used to run Redix. After you have that, you'll want to run ./redix_linux_amd64 –h to be sure all is well as it'll show the help, you'll get such a response:

Usage of ./redix_linux_amd64:
  -engine string
     the storage engine to be used (default "badger")
  -http-addr string
     the address of the http server (default ":7090")
  -resp-addr string
     the address of resp server (default ":6380")
  -storage string
     the storage directory (default "./redix-data")
     verbose or not
  -workers int
     the default workers number (default 1) 

Let's note that there is also a Docker image for quicker installation with the following command:

docker run -P -v /path/to/redix-data:/root/redix-data alash3al/redix 

Running Redix

When it comes to running Redix, it's a relatively simple process, being a matter of executing some commands in the command line. For this, ./redix_linux_amd64 is the executable. Once ran the command, you'll want to access http://machine_ip_address:7090/ to see the following response as JSON result:

{"message":"welcome to redix real-time db :)","success":true}

Once you see this, it means that everything is working as expected.

Setting Redix's Configurations

In the previous section, we got to see some of the important configurations that are possible with Redix. Essentially there is no need for any configuration files. Rather, you can just specify the following options below when loading your non-relational store:

  • engine: This defines the storage engine to be used. The default setting is badger.
  • http-addr: This specifies the address of the http server. The default is the current machine on port 7090.
  • resp-addr: This denotes the address of the resp server. Th default is the current machine on the port 6380.
  • storage: This serves as the storage directory. The default is ./redix-data.
  • workers: This states the number of workers. The default is 1.
  • verbose: This determines whether it'll be verbose or not.

The Features of Redix

As many other database engines, Redix has its own way to define data or performing queries on it. Redix supports data structure such as strings, hashes, lists, and sets. Some of the available features are:

  • Core data structure manipulations extensible storage engine.
  • Publish or subscribe using web hook and web socket.
  • Working with any available redis client including redis-cli.
  • Helpers commands for time, encoding and random: Time, Encode <hex|md5|sha1|sha256|sha512> <payload>, RANDINT, RANDSTR, RATELIMIT

The DB Engines of Redix

Even though Redix uses the same RESP protocol as Redis, the two of them are not complete interchangeable with each other. Redix has some specific features of Redis, but does not include all of the features of Redis.

They may be similar in terms of key-value way to store stuff, including the commands to interact with our data and the core protocol used for storage. However, Redix in addition also allows to use different kind of engine which is a great feature leading the store to be multi-model further.

Redix also supports many engines within the most popular and used are badger (inspired by Facebook RocksDB) and bolt (inspired by LMDB), here are some others:

  • level based on leveldb
  • null
  • sqlite

Example Commands

Let's perform some operations to our data store using redis-cli (hope installed, if not here's a guide), we first run our Redix:

  • redis-cli -p 6380 set key1 "value 1": defines "value 1" for the key key1 i.e key1 = "value 1"
  • redis-cli -p 6380 set key2 "value 2" 10000: here key2 has value2 as value which will expire in 10 seconds.
  • redis-cli -p 6380 get key1: to load and print key1 value (value 1)
  • redis-cli -p 6380 hset key3 x y: means key3[x] = y
  • redis-cli -p 6380 hget key3 x: load/print key3's x value as it's a hash map
  • redis-cli -p 6380 encode sha512 message: outputs the sha512 encoded representation of text "message"


  • SET <key> <value> [<TTL "millisecond">]
  • MSET <key1> <value1> [<key2> <value2> ...]
  • GET <key> [<default value>]
  • MGET <key1> [<key2> ...]
  • DEL <key1> [<key2> ...]
  • EXISTS <key>
  • INCR <key> [<by>]
  • TTL <key> returns -1 if key will never expire, -2 if it doesn't exist (expired), otherwise will returns the seconds remain before the key will expire.
  • KEYS [<regexp-pattern>]


  • HSET <HASHMAP> <KEY> <VALUE> [<TTL "millesecond">]
  • HMSET <HASHMAP> <key1> <value1> [<key2> <value2> ...]
  • HDEL <HASHMAP> [<key1> <key2> ...] (deletes the map itself or keys in the map)
  • HMSET <HASHMAP> <key1> <val1> [<key2> <val2> ...]
  • HEXISTS <HASHMAP> [<key>].
  • HINCR <HASHMAP> <key> [<by>]
  • HTTL <HASHMAP> <key>, the same as TTL but for HASHMAP`


  • SADD <LIST> <val1> [<val2> ...] (alias of LUPUSH)
  • SMEMBERS <LIST> [<offset> <size>] (alias of LRANGE)
  • SCARD <LIST> (aliad of LCOUNT)
  • SREM <LIST> [<val1> <val2> <val3> ...] (alias of LREM)


  • ENCODE <method> <payload>, encode the specified <payload> using the specified <method> (md5, sha1, sha256, sha512, hex)
  • UUIDV4, generates a uuid-v4 string, i.e 44e38a44-95eb-4221-8118-b8594a711570.
  • UNIQID, generates a unique string.
  • RANDSTR [<size>, default size is 10], generates a random string using the specified length.
  • RANDINT <min> <max>, generates a random string between the specified <min> and <max>.
  • TIME, returns the current time in utc, seconds and nanoseconds
  • DBSIZE, returns the database size in bytes.
  • GC, runs the Garbage Collector.
  • ECHO [<arg1> <arg2> ...]
  • INFO

You can access more details of supported commands illustrated into the official documentation.


In this short article, we've seen how to install RedixDB and perform some operations on the badger engine on Alibaba Cloud ECS instance.

0 0 0
Share on

Alibaba Clouder

1,900 posts | 405 followers

You may also like