What is Redis? And when you should use it

In this article, we are going to talk about Redis, an open-source, in-memory, key-value NoSQL data store that you should know about and when you should use it.


What is Redis?

Redis is an open-source, in-memory, key-value NoSQL data store created by Salvatore Sanfilippo in the year 2009 when he and the co-founder of his Italian startup stepped up with a problem in the scalability of his Web 2.0 services.

The name Redis stands for Remote Dictionary Server. Time has passed, improvements have been made and today Redis is used as cache, database, message broker, queue, and streaming engine.

How Redis works?

Redis works inside the memory of the Server, which means that it can deliver responses in a matter of sub-milliseconds it can also be persistent by dumping the dataset to the disk.

Redis let you store data structures such as strings, lists, hashes, bitmaps, geospatial indexes, and streams. And you can run atomic operations like appending to a string, pushing a list to a string, or adding an incremental value to a hash.

Is Redis free?

Redis is an open-source project and it is free. But it also has his enterprise edition which is paid, you can try it for free for 14 days with some limitations. and without support. For commercial use, you will need an Enterprise Edition that is closed source and require a commercial License from Redis Ltd.

Is Redis Single-Threaded?

Redis is single-threaded, which means that you cannot execute two commands at the same time, you must wait for one to finish in order to execute the next one.

Is Redis distributed?

Redis is a remote centralized server, which means that a single instance of Redis is limited by the maximum memory of your server. Big companies tend to use more than one instance of Redis and distribute the queries between them.

There is a solution though called Redis Cluster.

What is Redis Cluster?

Redis Cluster is a solution that let you install Redis instances as masters or slaves. Each slave will have their master instance. The minimum Redis instances you will need to use it are three masters and three slaves.

Where can Redis be installed?

Redis can be installed in a linux-based system. But if you are using windows, don’t worry, you can put your Redis implementation in a Docker Container. (Lucky for you, here you have a little tutorial on how to download and Install Docker)

Making a Redis implementation in Docker

To install Redis in a new docker container we can open a PowerShell and do the following:

PS> docker network create -d bridge rediscon 
# This will set a new bridged connection from the container

PS> docker run -d -p 6379:6379 --name redisimplementation --network rediscon redis 
# Docker already have a Redis image in their server with the latest Redis version, so by doing this, you are downloading that image and running the container with the network we have declared before. 

# Now you can connect to your local redis implementation like this:
PS> docker exec -it redisimplementation  bash

# Let's enter to our redis-cli
root@f577b2322a65:/data# redis-cli

# And now lets insert and get a variable> set val "Redis Tutorial"
OK> get val
"Redis Tutorial"

# And finally, let's insert and get a list> rpush list "This"
(integer) 1> rpush list "is a Redis"
(integer) 2> rpush list "Tutorial"
(integer) 3> lrange list 0 2
1) "This"
2) "is a Redis"
3) "Tutorial"

How do I access this data from outside the Redis container?

Assuming you know something about python coding, for instance, we could do something like this:

import redis
r = redis.Redis(



Although this is not intended to be a coding article, I don’t like to leave you with loose ends and I really hope you can do something with all the information I write.

When should I use Redis?

You should use Redis when your application needs to access data very fast without delays, it’s an excellent NoSQL database you can rely on and It can be a friend for you when optimizing your apps. Sometimes, we need the data to be accessed right away like in Chat applications, Media Streaming, Session storing and Machine learning code that has big datasets and using a conventional database will take a long time.

This is when Redis comes as a potential and powerful tool to help us away.

Also, you can read more about Redis in their docs.

As always, hope you find this review useful and can use Redis in your next project!

Leave a Reply