# Redis vs Memcached

URL: https://softwaredictionary.org/compare/redis-vs-memcached
Last updated: 2026-10-06

In short: Both keep data in memory; Memcached is a plain, multithreaded cache, while Redis adds data structures, persistence, replication and messaging.

## What is the difference between Redis and Memcached?

Redis and Memcached are both in-memory key-value stores that answer in well under a millisecond, and both are most often used as a cache in front of a slower database. Memcached, written in 2003, is a pure cache: it stores opaque values under keys and does almost nothing else. Redis, created in 2009, is a data structure server: its values can be strings, lists, sets, sorted sets, hashes and streams, and it can work as a primary data store, not only as a cache.

The difference comes from scope. Memcached keeps its feature set tiny on purpose: values are plain bytes, items expire or are evicted when memory fills, and the data is gone after a restart. Its servers never talk to each other; the client hashes each key to pick one. Redis adds persistence to disk, replication, built-in clustering, pub/sub, Lua scripting and atomic operations on its data types, such as `INCR` on a counter or `ZADD` on a leaderboard, so work that would need a read-modify-write round trip with Memcached happens inside the server.

Their execution models differ too. Memcached is multithreaded and uses every CPU core in one process, which makes it very efficient for large, simple caches. Redis runs commands on one main thread, which keeps every command atomic, and scales out by running several instances or a cluster; newer versions use extra threads for network I/O. In practice both are so fast that the network is usually the bottleneck.

A common misconception is that Redis has made Memcached obsolete. For a large, disposable cache of serialized objects or HTML fragments, Memcached is still simpler to run and very memory-efficient, and many large sites still use it. The opposite mistake is treating Redis as only a cache: once you rely on its data types, persistence or pub/sub, Memcached is no longer a drop-in replacement. Since Redis changed its license in 2024, the Linux Foundation's open-source fork Valkey has offered the same commands.

| Aspect | Redis | Memcached |
| --- | --- | --- |
| Data model | Strings, lists, sets, sorted sets, hashes, streams and more | Plain keys and values; values are opaque bytes |
| Persistence | Optional snapshots and an append-only log on disk | None: data is lost on restart |
| Replication and clustering | Built-in replicas, Sentinel failover and Redis Cluster | None in the server; clients spread keys across nodes |
| Threading | Commands on one main thread; extra threads for network I/O | Multithreaded: one process uses every core |
| Value size | Up to 512 MB per value | Up to 1 MB per value by default |
| Extras | Pub/sub, streams, Lua scripting, transactions | Little beyond expiry, LRU eviction and simple counters |
| Best for | Caches plus sessions, counters, leaderboards, queues and messaging | Large, simple caches of serialized objects or page fragments |

## Choose Redis when

- You need more than strings: counters, sorted sets for leaderboards, hashes or streams.
- Data should survive a restart or be replicated to another server.
- You also want pub/sub messaging, queues or rate limiting from the same store.
- Several operations must happen atomically on the server, through transactions or Lua scripts.

## Choose Memcached when

- You only need a fast, disposable cache in front of a database.
- Values are serialized objects or HTML fragments the app can rebuild on a miss.
- You want one process to use many CPU cores with very little to configure.
- Your stack already runs it and needs nothing more.

## Frequently asked questions

**Is Redis faster than Memcached?**

For simple gets and sets they are close, and the network round trip usually dominates. Memcached makes better use of many cores in one process, while Redis can do more work per request thanks to its data types.

**Can Redis replace Memcached?**

Usually yes: Redis can act as a pure cache with eviction and expiry times, and most client libraries make the switch easy. The cost is a somewhat more complex server with features you may not use.

**Does Memcached save data to disk?**

No, by default everything lives in memory and disappears on restart. Treat it as a cache whose contents can always be rebuilt from the real database.

---

Software Dictionary: https://softwaredictionary.org/ · https://softwaredictionary.org/llms.txt
