Keys & TTLs

  • Namespaced keys: app:domain:entity:id.
  • Set TTLs per data volatility; use jitter to avoid thundering expirations.
  • Version keys on schema changes to prevent stale reads.

Stampede protection

  • Use SETNX/lock around rebuild; short lock TTL with fallback.
  • Serve stale-while-revalidate: return cached value, refresh asynchronously.

Serialization & size

  • Prefer JSON with bounded fields; compress only large blobs.
  • Avoid massive lists/hashes; paginate or split keys.

Operations

  • Monitor hit rate, command latency, memory, evictions.
  • Use connection pooling; set timeouts and retries with backoff.
  • Cluster/replica for HA; read from replicas if consistency allows.

Checklist

  • Keys versioned; TTLs with jitter.
  • Stampede controls in place.
  • Metrics for hit/miss/latency/evictions; alerts configured.