Memcached versus Redis
In short: Both keep data in RAM for fast access. Memcached is a plain key-value cache, Redis a data-structure server with many more features.
In more detail: For pure caching of page fragments or query results Memcached is enough. As soon as you need lists, counters, queues or durability, Redis is the choice.
In Depth
- Memcached: Strings as values, multi-threaded, simple distribution across servers done by the client (consistent hashing), no storage on disk.
- Redis: Strings, lists, sets, sorted sets, hashes, streams. Optional persistence (RDB snapshots, AOF log), replication, pub/sub, Lua scripts. The core is largely single-threaded.
- Eviction: Both delete by rules such as LRU when memory is full.
- Typical Redis jobs: Sessions, leaderboards (sorted set), rate limiting, job queues.
- Choice: Pure cache with very high throughput on many cores: Memcached. Anything beyond: Redis.
See also: Caching strategies