Course contentsShow
← Cloud and Infrastructure
Lesson 2689 of 2,98958. Caching StrategiesFree lesson

Memcached Fundamentals

Understand Memcached's simple key-value model and how it differs from Redis.

Memcached Fundamentals

You'll learn: How Memcached's simple key-value model compares to Redis and when its minimalist approach shines.

What is Memcached?

Memcached is a high-performance, distributed in-memory caching system designed for one purpose: storing and retrieving data blazingly fast. Unlike Redis, which evolved into a feature-rich data structure store, Memcached remains intentionally simple—a pure key-value cache.

The Simple Key-Value Model

Memcached stores data as simple key-value pairs in memory. You set a key with a value (typically a serialized object or string), and retrieve it later. That's it. There are no lists, sorted sets, or pub/sub channels like Redis offers.

Think of Memcached as a massive, distributed hash table spread across multiple servers. It uses consistent hashing to distribute keys across nodes, making horizontal scaling straightforward.

How Memcached Differs from Redis

The differences stem from design philosophy:

  • Data structures: Memcached stores only strings/binary blobs; Redis supports complex types (lists, hashes, sorted sets)
  • Persistence: Memcached is purely in-memory with no persistence; Redis can save to disk
  • Operations: Memcached handles simple get/set/delete; Redis offers atomic operations on data structures
  • Memory management: Memcached uses a slab allocator with LRU eviction; Redis is more flexible
  • Simplicity: Memcached has fewer moving parts, making it easier to reason about and debug

When to Choose Memcached

Memcached excels when you need:

  • Pure session caching or fragment caching
  • Simplest possible architecture
  • Highly predictable latency
  • Multi-threaded performance on a single server

Key Takeaway: Memcached is a focused, high-performance key-value cache that trades Redis's rich features for simplicity, making it ideal for straightforward caching scenarios where complex data structures aren't needed.