Redis vs Memcached

intermediate redis memcached comparison

This is the classic Redis interview question. The short answer: Redis is a data-structure server with optional persistence; Memcached is a pure in-memory cache for strings. Both are blisteringly fast. Both speak text protocols. They overlap in the “cache strings” use case and diverge everywhere else.

Side by side

Redis
Strings, lists, hashes, sets, ZSETs, streams, bitmaps, HLL
Single-threaded command exec
Persistence: RDB + AOF
Replication + Cluster + Sentinel
Pub/Sub, Lua scripting, transactions
TTL per key
Value size: 512 MB
Memcached
Strings (and binary blobs) only
Multi-threaded
No persistence — cache lost on restart
No native replication
No pub/sub, no scripting
TTL per key
Value size: 1 MB (default)

When Memcached actually wins

Memcached is multi-threaded. If we’re running a pure cache on a 32-core box and our workload is “millions of GET/SET on plain strings”, Memcached can use every core in parallel. Redis would need clustering or I/O threads to match it.

So: huge servers, simple string caching, no need for anything beyond GET/SET/DEL → Memcached is a fine pick.

When Redis wins (which is most of the time)

The moment we need anything beyond “key → string”, Redis wins. Want to push a job onto a queue? Sorted leaderboard? Atomic counter? Set intersection for “friends in common”? Memcached can’t do any of that.

# Try this in Memcached. You can't.
ZADD leaderboard 100 alice
LPUSH queue "job-1"
SINTER tags:redis tags:nosql
HSET user:42 name "Alice" age 30

Persistence

Memcached is purely volatile. Restart the server, you lose everything. That’s fine for a cache — fall back to the DB and rebuild.

Redis offers two modes that work together:

  • RDB — point-in-time snapshots, low overhead
  • AOF — append-only log of every write, replayed on startup

This means Redis can act as a durable store, not just a cache. Many teams use Redis as the primary store for things like session data, rate-limit counters, and feature flags.

Replication & high availability

Memcached: nothing built-in. You shard client-side with consistent hashing and accept that node loss = cache loss.

Redis: built-in primary-replica replication, Sentinel for automatic failover, Cluster mode for sharding across nodes with automatic resharding. Redis is closer to a real database in this respect.

Eviction policies

Both support LRU eviction when memory fills up. Redis offers more knobs — LFU, TTL-based, random, allkeys vs volatile — and lets us pick per use case via maxmemory-policy.

CONFIG SET maxmemory 2gb
CONFIG SET maxmemory-policy allkeys-lru

The interview soundbite

“Memcached is a focused, multi-threaded string cache — great if that’s all you need. Redis is a single-threaded data-structure server with persistence, replication, and pub/sub. In 2026 the industry has mostly converged on Redis because the extra features pay for themselves the first time you need a queue, leaderboard, or rate limiter.”