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

Image for post
Image for post

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
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:

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:

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:

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:

Strings

HASHES

SET

SET

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

Conclusion

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

Original Source

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store