English for Memcached

Learn the English vocabulary for discussing Memcached's caching model, eviction behavior, and common failure modes with a backend team.

Memcached looks simple on the surface — it’s just a key-value store in memory — but its eviction behavior and lack of persistence trip up teams that assume it behaves like a database. Being precise in English about what Memcached guarantees, and what it doesn’t, prevents a lot of confusing incidents where “the cache lost data” gets treated like a bug instead of expected behavior.

Key Vocabulary

Slab allocator — Memcached’s memory management scheme, which pre-divides memory into fixed-size chunks (slabs) grouped by item size, rather than allocating memory freely per item. “We’re seeing wasted memory because of slab allocation — items just over a size boundary get bumped into a much larger slab class than they need.”

Eviction — the process of removing older items from the cache to make room for new ones once memory is full, typically using a least-recently-used policy within each slab class. “Cache hit rate dropped because we’re evicting items faster than expected — one oversized workload is crowding out everything else in its slab class.”

Cache stampede — a surge of simultaneous requests that all miss the cache at once (often right after a key expires) and hammer the backend database simultaneously. “When that popular product page’s cache entry expired, we got a cache stampede — a thousand requests hit the database in the same second trying to regenerate it.”

TTL (Time to Live) — the expiration duration set on a cache entry, after which Memcached treats it as gone even if memory pressure never forced an eviction. “That stale data you saw was because the TTL was set to twenty-four hours — it wasn’t evicted, it just hadn’t expired yet.”

Cache stampede protection (a.k.a. locking / early recomputation) — a pattern where only one request is allowed to regenerate an expired cache entry while others wait or serve slightly stale data, preventing a stampede. “We added stampede protection so only the first request after expiration hits the database — everyone else gets the still-cached value for a few extra seconds while it recomputes.”

Common Phrases

  • “Is this a real eviction, or did the TTL just expire naturally?”
  • “We might be losing memory to slab allocation — what size are these items compared to their slab class?”
  • “This spike looks like a cache stampede right after that key expired.”
  • “Should we add stampede protection around this endpoint’s cache key?”
  • “What’s the TTL on this entry, and does it match how often the underlying data actually changes?”

Example Sentences

Diagnosing a cache miss spike: “The database load spike lines up exactly with this key’s TTL expiring — that’s a classic cache stampede, not a traffic increase.”

Explaining memory waste: “We’re wasting almost thirty percent of our cache memory because of slab allocation — a lot of our items are just a few bytes over a size class boundary.”

Proposing a fix: “I want to add stampede protection on the homepage cache key so we don’t hit the database with a thousand simultaneous queries every time it expires.”

Professional Tips

  • Distinguish eviction from TTL expiration explicitly when explaining missing data — one means memory pressure, the other means the entry simply aged out as designed.
  • Bring up slab allocation specifically when memory usage looks inefficient — it’s a Memcached-specific quirk that a generic “increase the cache size” fix won’t solve.
  • Name cache stampede as the root cause when a traffic spike coincides exactly with a key’s expiration — it reframes the incident from “sudden load” to a known, fixable pattern.
  • Propose stampede protection as a concrete mitigation rather than just “add more cache” — it shows you understand the mechanism, not just the symptom.

Practice Exercise

  1. Explain, in one sentence, the difference between an evicted cache entry and one that expired via TTL.
  2. Describe what a cache stampede is and one technique to prevent it.
  3. Write two sentences explaining to a teammate why wasted cache memory might be caused by slab allocation rather than simply needing a bigger cache.