Introduction to Redis — An In-memory Database

BySudhanshu Kumawat
June 2nd . 5 min read
Introduction to Redis — An In-memory Database

Redis is one of the most popular NoSQL databases on the market. It was created in 2009 as a response to the limitations of other databases.

Some main advantages of Redis are that it uses no SQL but supports data structures like hashes, sets, and lists accessing them via simple client libraries in different programming languages such as Java, Ruby, Python, and JavaScript (Node.js).

If you are running a website or web application that needs really fast data storage with lots of capabilities, then Redis is the perfect solution.

Let us see why we should use Redis in our project.

Overview about Redis

Redis- which stands for ‘ Remote Dictionary Server’- is an open source, in-memory data structure store.

It’s a NoSQL or non-relational database, which means, there are no tables, and it does not define relations between data sources.

While it basically stores data in key-value format, it also provides efficient support for string-based key-value data storage, sorted sets, hash tables, and multiple data structures like lists, sets, etc.

Key Features of Redis -

redis – 1.jpg

What is it that makes Redis a go-to choice for databases? Well, the reasons are many, and we have listed some major ones-

  • Open source and free to use.
  • It is written in C and can be used on a wide range of systems from Linux, Unix, Microsoft Windows to Mac OS X.
  • Runs on a single server or distributes over different servers.
  • No-SQL data structure store, but supports the same data types as key-value stores such as AWS ElastiCache or Memcached.
  • Extremely scalable and have usage in caching, data structures and sets, lists, blogs, and ad serving.
  • Currently used by several large websites including Twitter and Pinterest.

Get Started with Redis

Let’s see how to install Redis on Linux machines, so you can get the best out of it.

Install redis-server by hitting this command:

sudo apt-get install redis-server

Enable the server daemon by hitting this command:

sudo systemctl enable redis-server

Start up the service using the above command:

sudo systemctl start redis-server

Now, check status using above command:

cat /var/log/redis_6379.log

Redis is now installed and running. Type the following command to check the server installation:

redis-cli ping

The default Redis port is 6379 but some services/applications may prefer to change this.

The basic usage of Redis Client is to issue a command and to check the result. If there’s no error, it returns the result, otherwise returns an error message.

If you want to send an arbitrary command, you can type it as shown in the following example-

/usr/bin/redis-cli -h> set n 3 3

Here, we are setting n variable is to 3 (integer value). You’ll notice that the value is not in the disk yet, and you won’t see any change on your terminal window.

Pros & Cons of Redis

We have already learned about the features and functionalities of Redis, now we’ll see the popular pros & cons of Redis-


Redis is one of the most popular key-value store databases. It integrates well with many frameworks, and it’s fast, reliable, and easy to set up and use.

redis – 2.jpg

  • Feature detection and troubleshooting at the application level.
  • It can be configured to support multiple data types and meet particular performance needs: a cache of frequently accessed items; a histogram; transactional records; delay or bounded queues.
  • Redis can be used to bolster feature testing during development. For instance, you can use it to store and quickly retrieve the names of all your user roles or build an in-memory analytics engine.
  • You might also find Redis useful as a dependency container to hold transient information generated from RDBMS queries that would otherwise cause a round-trip to the server.
  • Storing application data in Redis is fast (scales with speed of RAM) and because your data is available in memory, it’s never lost due to a system failure.


However, that is where it’s true strengths end. Its disadvantages may be more important than its advantages for some uses.

- Lack of persistence

Redis has no built-in persistence. Therefore, if you are using it in a production environment, you must use some other means to persist the data. A few different storage backend exist, ranging from simple to complex (Redis is usually combined with Memcached or other in-memory data store).

- No support for transactions

Redis has no support for transactions either as found with databases such as MySQL, PostgreSQL or Oracle Database (Oracle Database 11g and 10g do support transactions, but they are not fully compatible with Redis).

- Tuning Redis

Tuning Redis is not a trivial process, and it’s easy to forget about something important. A lot of the tuning parameters are dependent on your use cases, which aren’t always obvious.

- No support for clustering

With no built-in clustering, you’ll have to resort to third party tools or develop your own if you want to scale out Redis across multiple nodes, or even multiple data centers.

Unfortunately, there are no standard interfaces for one application to talk directly with another through Redis. This means that scaling and redundancy must be handled by an external tool (i.e. HAProxy) if an application needs to communicate with another server using Redis as the message broker.

However, despite the mentioned cons of Redis, it’s getting popular everyday due to its obvious and handy features.

Thanks for reading this blog! If you find it helpful, let us know through your claps & comments.😊🙌