Redis Cache vs Store
Use as cache only.
Overview
Redis is excellent as a cache. As a primary data store it produces silent durability bugs and recovery surprises. Treat Redis as ephemeral by default; durability is a deliberate exception with documented trade-offs.
- Cache by default. Use Redis to memoise computed values, session state, and rate-limit counters. Source of truth lives elsewhere.
- Persistence trade-offs. AOF and RDB add durability at the cost of latency and operational complexity. Use only when justified.
- Memory-only by design. Redis assumes the working set fits in memory. Configure
maxmemoryexplicitly with a known eviction policy. - Per-key TTL plus eviction policy. TTL on every cache key;
allkeys-lruor similar eviction at the cluster level.
The approach
Three habits keep Redis use correct: cache-only as the default, persistence-awareness when durability is genuinely needed, and documented rationale per cluster.
- Cache-only default. Redis as cache; PostgreSQL or DynamoDB as primary store. Treat Redis loss as recoverable from source of truth.
- Persistence aware. When durability is needed, configure AOF with
appendfsync everysec. Understand the trade-off explicitly. - Per-key TTL. Every cache key has a TTL. Without TTL, Redis becomes an unbounded memory leak.
- Eviction policy plus documented use.
maxmemory-policyset per cluster; per-Redis use case documented in the runbook.
Why this compounds
Each correctly-used Redis cluster produces sub-millisecond latency for the right workloads. The team learns Redis through repeated correct use; mistakes around persistence and durability shrink.
- Latency. Cache use produces sub-millisecond reads. User-facing performance benefits directly.
- Operational fit. Right use matches Redis strengths. The wrong use produces durability bugs that surface during incidents.
- Engineering culture. Cache-aware decisions replace tribal preference. New services pick the right tool from design review.
- Year-one investment, year-two habit. The first cluster is investment. By the third, every team knows the pattern.