Introduction to Redis

In this tutorial, we are going to learn about Redis step by step. Let’s get started and let’s see what is Redis.

Redis is an open-source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams.

Let’s break the Redis word into 3 parts.

RE(Remote ) DI(Dictionary ) S(Server)

So Redis is an acronym for the Remote Dictionary server and in a very basic word, Redis is a key-value store.

What is this key-value store means?

Redis server/store that stores data as key-value pair. As an example, “Name”= “Kasun”. Here “Name” is the Key and “Kasun” is the value. As because Redis can use to read and write data Redis can use as a Database.

Let us find how the user interacts with the Redis key-value store.

We can WRITE data to the Redis server using SET “name” “Kasun” and also we can READ data from the server using GET “name”.

So this is how simple and straight forward the Redis can be.

Let’s look at some useful features.

  • It's a NoSQL database. This means that unlike MySQL and Oracle databases it does not have structures like tables/rows/columns/functions and procedures. And it does not use statements like SELECT, UPDATE, INSERT, and UPDATE.
  • Redis uses data structures to store data. Primary data structures like String, Lists, Sets, Sorted Sets, and Hashes. Extra data structures like Bitmaps, HyperLogLogs, Geospatial Indexes.
  • Interaction with data is command based. If you want the full list of commands:
  • It’s an in-memory database with persistence options. This means that Redis keeps the data in the memory(cache) and does not write to the disk then it makes it very very fast. However, Redis has an option to write the data to the Disk.

There are some major features of Redis.

  • Performance
  • Flexibility
  • Language Support
  • Compatibility
  • Durability
  • Scaling

You know now Redis is super fast. But we do not know how fast exactly.

Here you can find all the steps for performances and speed of Redis. Performance od Redis can go up to 120000 requests per second and even more.

You know that Redis is a NoSQL data store and we do not need anything to define like tables, rows, and columns. No need for statements. The READ and WRITE data to the Redis server is very very simple and straight forward.

How Durable is Redis? In Redis, it although works with the data in memory/cache. But it has the option to write on the disk. And this option is configurable. And also we can use Redis as a Caching system or a full-fledged Database.

Here you can find entire languages and clients supported for Reids.

So one of the major use of Redis is it can be used as a secondary Database for your applications to make transactions faster. Let us look at an example.

In your system the requests that lead to service very fast and very quick. You can store data in Redis memory. From there you can serve data to the application. The rest of the data can store in the main database. Redis is just a cache, it provides a high-speed data store, whereas a database is slower but more reliable and with more features. Your application is responsible for getting data from Redis, and if it doesn’t find it, pulling it from the database and adding it to Redis, with appropriate expiration and invalidation mechanics.

Redis has a very good master-slave replication feature. You can use different instances of Redis. Master can be a write-only data store. And also one of the slaves can be used for read-only. And other slaves can be used to write the data to the Disk. It can increase the performance while the master and one of the slaves doing read and write.

So Redis has a text file in which you can put all the configurations on a single file. It is single-threaded. And it also eliminates all the issues of thread written for some other thread locking timeouts and similar issues. There is a pipelining feature in Redis. You can cluster multiple commands and send them at once.

Here you can find the well-known companies and som popular sites which use Redis.

I hope now you know Redis much better now.

Thank You!

--

--

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
Kasun Dissanayake

Senior Software Engineer at IFS R & D International || Former Software Engineer at Pearson Lanka || Former Associate Software Engineer at hSenid Mobile