When a database query or a rendered page can be reused, recomputing it from scratch on every request is wasted work. An in-memory object cache stores those results in RAM so they’re served in microseconds. The two dominant choices are Redis and Memcached — both fast, both battle-tested, but suited to different jobs. This guide compares them so you can pick the right one for WordPress, an API, or a high-traffic application.
What They Have in Common
Both Redis and Memcached are in-memory key-value stores that sit between your application and your database. They both dramatically reduce database load, support multiple languages, and are trivial to drop into most frameworks. For simple “store this value, fetch it later” caching, either will make your app noticeably faster.
Head-to-Head Comparison
| Feature | Redis | Memcached |
|---|---|---|
| Data structures | Strings, lists, hashes, sets, sorted sets, streams | Strings only |
| Persistence to disk | Yes (RDB / AOF) | No |
| Replication / HA | Yes (replicas, Sentinel, Cluster) | No (client-side sharding) |
| Multi-threaded | Mostly single-threaded core | Yes, multi-threaded |
| Pub/Sub & queues | Yes | No |
| Max value size | 512 MB | 1 MB (default) |
| Eviction policies | Many configurable | Simple LRU |
When to Choose Redis
Redis is the more capable, feature-rich option. Choose it when you need:
- Rich data types — counters, leaderboards (sorted sets), queues, or session data.
- Persistence — the cache survives a restart instead of starting cold.
- High availability — replication and failover for production resilience.
- Pub/Sub or message queues — Redis doubles as a lightweight broker.
For WordPress, Redis is the usual recommendation — the popular object-cache plugins target it, and persistence means your cache stays warm.
# Quick Redis test
redis-cli ping # -> PONG
redis-cli set greeting "hello"
redis-cli get greeting # -> "hello"
When to Choose Memcached
Memcached is simpler and, for one narrow job, excellent. Choose it when:
- You only need simple string caching — fragments, query results, rendered HTML.
- You want to cache lots of small objects and saturate multiple CPU cores (it’s multi-threaded).
- You don’t need persistence, data structures, or replication.
Its multi-threaded design can edge out Redis for very high volumes of small, simple get/set operations.
Performance: The Honest Answer
For basic caching, raw speed between the two is close enough that it’s rarely the deciding factor — both serve reads in well under a millisecond. The decision should be driven by features, not micro-benchmarks: if you need anything beyond simple key-value strings, Redis wins by default. If you truly only need a fast, simple cache and want multi-core scaling for tiny objects, Memcached is a clean fit.
Conclusion
Both tools cache in memory and slash database load — the difference is scope. Memcached is a lean, multi-threaded string cache; Redis is a versatile data store with structures, persistence, and high availability. For most modern apps — and WordPress in particular — Redis is the safer default because it does everything Memcached does and far more. Reach for Memcached only when its simplicity is exactly what you want.
