Understanding Redis and why we use it


Introduction
Hey fellow developers! Today, We’re going to talk about Redis, and in this post, I’ll focus more on the concept of it rather than diving deep into code.
Of course when we start talking about Redis we start with the famous definition:
Redis is an in-memory key-value data store.
It is mainly used for caching data for faster retrieval, but it can also serve as a queuing system, especially when combined with background processing tools like Sidekiq (and that’s a topic for another article)
Real-Life Example: Why Use Redis?
Imagine you have a web page with a button that generates a summary report — something that involves a lot of calculations and database queries on a large dataset.
If you don’t use caching or background jobs, clicking that button will immediately trigger all the heavy work directly, querying the database and performing all the calculations before responding to the user. This might result in a request timeout, especially in production where multiple users might be doing the same thing.
This is where Redis can help.
Think of Redis as part of a queue system. When you click the button, instead of making the user wait for all the work to finish, your application can enqueue a background job (for example, using Sidekiq, which uses Redis behind the scenes). Redis holds the job in memory, and Sidekiq processes it asynchronously — freeing up your app preventing from waiting for the request and the app can respond immediately with something like, “Your report is being generated.”
Caching with Redis
Let’s extend that example a bit.
Once the report is generated, you can cache it in Redis. That way, the next time someone clicks the button — and if nothing has changed — the cached report can be returned instantly.
No recalculations. No long waits. Just a blazing-fast response.
Final Thoughts
I intended this to be a simple example. When I first heard about Redis, I struggled to understand what it is and why we use it. And to be honest, I’m still learning.
But I hope this post helps someone like me — someone starting out and trying to wrap their head around how Redis can be useful in real applications.
Subscribe to my newsletter
Read articles from Abdelrahman Gamal directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
