Skip to content
Devgo

Memcached

A simple, multithreaded in-memory key-value cache for strings only. No persistence, no replication, no complex types. Older than Redis and still excellent for pure, simple, high-throughput caching.

When to use
  • Pure caching of simple values where simplicity and raw throughput matter.
  • When you don't need Redis's data structures.
When not to
  • When you need persistence, replication, or rich types (use Redis).
  • As a queue or pub/sub.

Definition

Memcached is a distributed in-memory cache storing string key-value pairs across multiple nodes. It's multithreaded, has a slab allocator, and intentionally offers no persistence or — it's a pure cache.

Why it exists

To offload DB reads with the simplest possible, very fast cache. By avoiding persistence/, it stays lean and multithreaded, saturating a multi-core box better than single-threaded for plain GET/SET.

How it works

Clients hash keys to pick a node (consistent hashing spreads load). Each node is multithreaded with per-thread slabs. per slab class. No persistence: a restart empties the cache. No : a node loss drops its keys.

Scaling limits

Strings only — no lists/sets/streams. No persistence or by design. A node failure or restart loses data (fine for a cache, not for durable state). Slab sizing can waste memory if value sizes are skewed.

Cost shape

RAM-only, cheap per op, high throughput per node. Blow-ups: memory waste from slab-class mismatch and cache warm-up after restarts.

Alternatives

  • Redis — Rich types, persistence, , but single-threaded per core.
  • CDN cache — Edge caching for responses, not app-level KV.

Failure modes

  • Cold cache after restart causing a DB stampede.
  • Slab imbalance wasting memory.
  • Single-node loss dropping a slice of the cache.

, , ,