Redis and Memcached are the two dominant distributed caching technologies, with Redis winning most new deployments due to its rich data structures and persistence options. Redis supports strings, hashes, lists, sets, sorted sets, HyperLogLog, streams, and geospatial indexes — enabling use cases far beyond simple key-value caching. Hazelcast provides an in-memory data grid with distributed computing capabilities, favored in Java-heavy enterprises. Redis Cluster supports horizontal sharding across 16,384 hash slots with automatic failover.

Key Points

  • Redis data structures: String (simple cache), Hash (object cache), List (queues, activity feeds), Set (unique visitors), Sorted Set (leaderboards, rate limiting), Stream (event log).
  • Redis Cluster: shards data across nodes using CRC16 hash slots (16,384 total); requires at least 3 primary + 3 replica nodes for fault tolerance.
  • Redis Sentinel: high-availability solution for non-cluster deployments — monitors primaries, performs automatic failover, handles client reconnection.
  • Memcached: simpler than Redis — only string values, no persistence, multi-threaded (better CPU utilization on high-core machines), no replication built-in.
  • Redis persistence: RDB (point-in-time snapshots) and AOF (append-only log) — use both for durability; AOF with fsync every second gives <1s data loss window.
  • Hazelcast: distributed Java objects (IMap, IList, IQueue), distributed compute (EntryProcessor runs logic co-located with data), favored for distributed caching in Spring apps.
  • Redis Pub/Sub and Streams: Pub/Sub for fire-and-forget messaging; Streams for durable, consumer-group message processing — Redis Streams is Kafka-lite for moderate throughput.
  • Eviction policies: Redis supports LRU, LFU, TTL-based, and random eviction — configure maxmemory-policy=allkeys-lru for cache-only deployments.

Real-World Example

Instagram uses Redis for storing follower lists and activity feeds for 2 billion users. Their deployment uses Redis Cluster with 100+ shards, custom consistent hashing, and Python client connection pooling — Redis handles 6 million requests/second at peak.