Redis vs Memcached
Cache choice.
Overview
Redis and Memcached are both in-memory caches that fit different shapes of workload. Redis ships rich data structures, optional persistence, and replication; Memcached ships a leaner key-value store with multi-threading and a slab allocator that avoids fragmentation. Defaulting to Redis is the right call for most modern workloads; defaulting to Memcached makes sense when simplicity, predictable allocation, or pure key-value semantics dominate.
- Redis: rich data structures. Strings, lists, hashes, sets, sorted sets, streams. Application logic moves into the cache where it belongs.
- Memcached: simple and fast. Key-value with multi-threaded throughput. Stays out of the way.
- Redis: persistence option. RDB snapshots or AOF append-only logs. Durability when the cache acts as a primary store.
- Memcached: predictable performance. Slab allocator avoids fragmentation. Steady tail latency under sustained load.
The approach
Three habits keep the cache choice rational: Redis as the default for most workloads, Memcached for the workloads where pure key-value plus predictable allocation actually matter, and a documented rationale per cache.
- Redis default. Most use cases benefit from data structures, replication, or pub/sub. Ship Redis unless a specific reason argues otherwise.
- Memcached when simplicity dominates. Pure key-value, predictable allocation, multi-threaded throughput. Less code, less to operate.
- Redis Cluster for sharded scale. When data exceeds a single node and the workload benefits from Redis features.
- Memcached for predictable allocation plus documented choice. Slab allocator pays off under sustained load; per-cache the rationale documented for the next engineer.
Why this compounds
Each correct cache choice compounds across every access. The team’s caching mental model deepens; new services inherit the convention rather than rediscovering it through outage post-mortems.
- Operational fit. Right cache for the workload means fewer surprises during scale.
- Cost efficiency. Right tier and right data shape match the budget.
- Feature fit. Application logic that fits Redis natively stops being implemented in the application layer.
- Year-one investment, year-two habit. First deliberate cache choice takes thought. By the third service, the methodology is settled.