Redis caching: when to add it and what changes when you do
Redis is an in-memory data structure store. Where it fits - caching, sessions, rate limits - and the stale-data and failure designs you must settle first.
"Just add Redis" is the most common answer to a slow app, and often the right one - but Redis is an infrastructure component with real failure modes, not a magic speed switch. Knowing what it is good at, and what changes when you add it, keeps the cache from becoming your next outage.
This guide covers what Redis is, the workloads it fits, and the questions to settle before adding it, following Redis's own documentation, checked on 19 November 2026.
What Redis is
Redis is an in-memory data structure store. Its documentation describes it as a fast cache, data structure server, and document and vector query engine, used for real-time data-driven applications. Two properties explain its speed: data lives in memory rather than on disk, and its operations on built-in structures - strings, hashes, lists, sets, sorted sets and more - are simple and predictable, so lookups do not pay the planning and I/O costs a general-purpose database pays.
Where Redis genuinely fits
- Cache for expensive reads. The classic: store the result of a slow database query or external API call, serve repeats from memory, and keep the caching rules for shared data strict from day one.
- Session storage. Server-side sessions that any app instance can read, which makes horizontal scaling and deploys painless.
- Rate limiting and counters. Atomic increments with expiry are the standard building block behind request budgets - see rate limits and spending caps.
- Ephemeral coordination. Short-lived locks, job queues, leaderboards and other state that is useful now and worthless later.
What changes when you add a cache
- You now have two sources of truth. Every write has to decide what happens to the cached copy: invalidate it, update it, or let it expire. Stale-cache bugs are logic bugs that only appear in production timing.
- Failure behavior must be designed. If Redis is down, does your app fall back to the database (slower but correct), or fail? A cache outage that hammers the database with uncached load can take down both systems.
- Memory is the capacity limit. Decide the eviction policy and maximum size deliberately. An unbounded cache is an incident scheduled for later.
- Expiry is a product decision. How stale can this data be, per key type? "It depends" is the correct answer, which is why someone has to answer it.
When you do not need it yet
Skip Redis while your queries are the actual problem: a missing index or an accidental N+1 fixed in the database is permanent, while a cache over the same problem is rent you pay forever. Database indexes explained and reading a query plan cover that side. And if your bottleneck is a few hot read queries under moderate load, PostgreSQL itself is often fast enough once the queries are sane. Add Redis when you can name the workload it serves and the failure mode you have designed for - not as a reflex.
Sources
- Redis documentation, get started: https://redis.io/docs/latest/develop/getstarted/
- Redis project README: https://github.com/redis/redis
Drafted with AI assistance from these sources. Cache design depends on your data's freshness requirements and failure tolerance; test cache-loss behavior before relying on one in production.