Choosing engine

  • Redis: rich data types, persistence, clustering, scripts; good for queues/rate limits.
  • Memcached: simple KV, pure in-memory, fast; great for stateless caches.

Design

  • Namespaced keys, versioned; TTL with jitter; avoid giant values.
  • Pick eviction (LRU/LFU); monitor hit rate and evictions.
  • Stampede control: locks/SETNX, stale-while-revalidate, per-key backoff.

Ops

  • Pooling + timeouts; alert on latency, evictions, memory fragmentation.
  • For Redis, persistence config (AOF/RDB) matched to durability needs; replicas for HA.
  • For Memcached, spread slabs; watch for evictions of hot slabs.

Checklist

  • Engine chosen per use case; durability/HA decided.
  • TTLs + jitter; stampede protection in place.
  • Metrics for hit/miss/evictions/latency.