Redis and Memcached are both in-memory key-value stores used to cache database results, sessions and rendered fragments. For simple caching, either works. Redis does far more; Memcached does one thing very efficiently.

At a glance

Redis (and Valkey) Memcached
Data model Strings, hashes, lists, sets, sorted sets, streams, bitmaps, JSON (module) Strings (byte blobs) only
Persistence Optional (RDB, AOF) None — memory only
Replication / HA Replicas, Sentinel, Cluster None built in (client-side sharding)
Pub/sub, queues Yes No
Threading Single-threaded command execution (I/O threads optional) Multi-threaded
Memory efficiency for small values Good Very good (slab allocator)
Max value size 512 MB 1 MB by default
Eviction Configurable policies (LRU, LFU, TTL-based) LRU
Lua scripting / transactions Yes CAS only
Typical uses Cache, sessions, queues, rate limiting, leaderboards, locks Pure cache

When Memcached is enough

  • You only need a volatile cache of serialized objects.
  • Very high throughput of simple gets/sets across many cores.
  • A long-established stack already uses it (older PHP apps, some frameworks’ defaults).

Memcached’s multi-threading lets one instance use all cores for simple operations, and its memory layout is efficient for many small items.

When Redis is the better choice

  • You want one service for cache, sessions, queues and locks — Laravel, Rails/Sidekiq, Celery, BullMQ all use Redis.
  • Data structures save work: counters (INCR), sorted sets for leaderboards, sets for tags, hashes for objects.
  • Rate limiting and distributed locks with atomic operations or Lua scripts — see API rate limiting.
  • Persistence: sessions or queue jobs should survive restarts.
  • Pub/sub for real-time features — see Redis pub/sub.
  • Replication and failover.

For most new projects, Redis (or its open-source fork Valkey) is the default choice. See Valkey vs Redis.

WordPress

Both work as a persistent object cache. Redis with the Redis Object Cache plugin is the most popular combination and lets you flush per site/prefix easily. Memcached plugins exist too. See WordPress Redis object cache.

Laravel, Symfony, Django, Rails

All support both for caching. Redis additionally powers queues, broadcasting and locks, so most projects standardise on it to run one service instead of two.

Performance notes

On a single VPS, both answer in well under a millisecond — network round trips and serialization dominate, not the cache server. Differences matter only at very high request rates. Choose based on features, not micro-benchmarks.

Memory sizing

Whichever you use, set a memory limit and let the cache evict:

Security (both)

Neither should be reachable from the internet. Bind to 127.0.0.1 (or a private network), firewall the port, and use authentication (Redis requirepass/ACLs; Memcached SASL if exposed beyond localhost). Exposed Memcached servers have been abused for massive UDP amplification DDoS attacks — disable UDP (-U 0) on Memcached.

Install guides

Both are light enough to run alongside your web stack on any VPS plan.

  • Redis
  • Memcached
  • Caching