Introduction

redix is a hashtable service with multiple storage engines as backend.

redix uses RESP protocol (Redis serialization protocol), you can learn more about it from here, you can learn more about redis from here.

redix won't implement all redis features, but the core generic features (the basic flat key-value model) that enables anyone to implement redis like features.

redix server tries to use all available cores, so it can provide the maximum machine utilization as possible as it can to give you the best performance.

Why Redix?

redis, is an in-memory data store, it is perfect as well, forces you to map everything to key - value which sometimes simplifies the thinking regarding the job you're doing, by the time, redis is abused by us due to that simplicity then we started to face new issues especially the memory and the single-threaded model.

How could we store data on disk (read/write from/to disk)? How could we utilize the existing storage solutions but with simple redis interface? for sure there are many questions out there, most of them aren't in redis scope.

That is why I created redix, which exposes redis-like interface but the datasource is different which could be anything (for now it is postgresql and filesystem).

Installation

1)- Binary installation

  1. Goto the releases page.
  2. Select the release the matches your OS (Linux or Mac).
  3. Extract the binary file from the downloaded archive.
  4. Rename the extracted binary file as redix and copy/move it to your /usr/local/bin or any folder included in your $PATH env-var.

2)- Docker

  1. docker pull ghcr.io/alash3al/redix:latest

Running

assuming you followed the corresponding installation instructions above, and created a configurations file called redix.hcl in the current working directory containing the configurations content found here and edited to match your preferences, for more info about configurations click here.

1)- Binary

assuming that you have a postgresql server running on the local machine contains a database called redix.

$ redix ./redix.hcl

2)- Docker

assuming that you have a postgresql container named redixdb having a database called redix, and the engine part configurations in redix.hcl as follows:

engine "postgresql" {
     dsn = "postgresql://postgres@redixdb/redix"
}
docker run -v $(pwd)/redix.hcl:/etc/redix/redix.hcl --link redixdb -p 6380:6380 ghcr.io/alash3al/redix

Connecting

you can connect to redix using any redis client/library, here we will use the redis-cli command:

redis-cli -p 6380

Configurations

redix is using a configuration language called hcl, here is a configurations example named as (redix.hcl):

// server block contains the configurations related to redix server
server {
  // redix is modular, "we can have multiple interfaces not only redis interface"
  // currently the supported interface is redis interface.
  redis {
    // which [address]:portNumber to let the server listen on
    listen = ":6380"

    // maximum number of connections allowed to the server instance in the same time
    max_connections = 100

    // whether to let the writes be async (done in background) or not?
    async = false
  }
}

// redix is modular, "we can have multiple storage engines to store the data"
// currently the supported engines are "postgresql" and "filesystem".
// in case you want to connect to "postgresql":
engine "postgresql" {
  // data-source-name regarding postgresql server configurations
  dsn = "postgresql://postgres@localhost/redix"
}

// in case you want "filesystem" to be your backend:
//engine "filesystem" {
//  // data-source-name: the directory to store the data files in
//  dsn = "./data/"
//}

Redis Commands

we don't support all redis commands, we create our own redis by implementing abstract commands only.

  • PING
  • QUIT
  • FLUSHALL
  • FLUSHDB
  • SELECT <DB index>
  • SET <key> <value> [EX seconds | KEEPTTL] [NX]
  • TTL <key> (not supported while using filesystem engine)
  • GET <key> [DELETE], it has an alias for backward compatibility reasons called GETDEL <key>
  • INCR <key> [<delta>], it has an alias for backward compatibility reasons called INCRBY (not supported while using filesystem engine)
  • DEL key [key ...]
  • HGETALL <prefix>, Fetches the whole data under the specified prefix as a hashmap
    $ 127.0.0.1:6380> set /users/u1 USER_1
    OK
    
    $ 127.0.0.1:6380> set /users/u2 USER_2
    OK
    
    $ 127.0.0.1:6380> set /users/u3 USER_3
    OK
    
    $ 127.0.0.1:6380> hgetall /users/
    1) "u1"
    2) "USER_1"
    3) "u2"
    4) "USER_2"
    5) "u3"
    6) "USER_3"
    ## in the hgetall response, redix removed the prefix you specified `/users/`
    
  • PUBLISH <channel|topic|anyword> <message here> (not supported while using filesystem engine)
  • SUBSCRIBE <channel|topic|anyword> (not supported while using filesystem engine)