What is Redis and when should you use it?

Redis is almost a household name in 2020. With every major tech company moving towards a microservices, service-oriented architecture, Redis is now more important than ever. In this article I am going to share what Redis is and some use cases. More specifically when to use it and when not to use it.

What is Redis?

What does that mean.

To look at this we need to look at historic caching solutions. Before we had a cache called Memcached. It is a simple cache that can be executed from the command line or in program. It will store the data in RAM to save time in database loads.

Memcached architecture. Icons from Icons8.com. Image by Justin Barnett
Redis Architecture

Why is this important? Database loads typically load data from disk, plus additional overhead with computational cost, is much slower than loading data directly from memory. With the invent of SSD’s the difference has drastically decreased, however with large databases this is still true.

Memcached has some simple operations that make it smarter than the general memory dump program, however it is limited in it’s scope.

We can think of Redis in a lot of ways as Memcached 2.0. It can do all the things Memcached can do, plus support some data structures that make additional operations available like

  • Sets
  • Sorted Sets
  • Queues
  • Trees
  • BitArrays
  • Streams

This is very powerful since this enables us to use it for complicated use cases like

  • Message broker (Pass messages between 2 different programs connected on the same network)
  • Search Indexes
  • Bloom Filters
  • Real time applications
Icons from Icons8.com. Image by Justin Barnett

When to not to use Redis?

  • Large Datasets (Memcached is better for you since the data is simple. Memcached can scale easily with instances)
  • Simple operations (If you are not going to be using Redis in a micro-services architecture or RT application, there’s very little argument on using Redis vs Memcached)

This is a simple operation in Memcached

Alternatively Redis can get complicated extremely quickly

When to use Redis?


This is important since fundamentally hosting your services in a container system like Docker means all your micro-services will not be able to access to each other without some sort of middleman. Redis in this case acts as a middle man and sends, or ‘brokers’, messages between containers

Real Time Applications

Constraints of Redis

  • There are no reserved keywords for strings as strings are stored as bytes
  • Maximum key, value size is 512MB
  • 2³² maximum keys
  • Single machine unless Redis is Clustered

In Conclusion