What it is
Redis and Memcached are in-memory data stores used to accelerate data access. Redis acts as a data structure store, while Memcached is a classic distributed object cache.
| Parameter | Redis | Memcached |
|---|---|---|
| Data types | Strings, Lists, Hashes, Sets, Geo, Bitmaps | Strings only |
| Persistence | Yes (RDB, AOF) | No |
| Replication | Yes (Master-Slave) | No (via third-party tools) |
| Multithreading | Limited (I/O threads since v6.0) | Full support |
| Transactions | Yes | No (Atomic CAS only) |
Performance
Both systems provide sub-millisecond latency. Memcached utilizes multi-core processors more efficiently due to its multithreaded architecture, offering an advantage in raw throughput for simple key-value pairs under heavy load. Redis, being primarily single-threaded, may lag in raw string R/W throughput but outperforms Memcached when dealing with complex structures, as processing occurs server-side without transferring the entire object to the client.
Configuration & complexity
Memcached is extremely simple to configure: memory management is handled via Slab Allocation, which prevents fragmentation but limits object size (1 MB by default). Redis requires detailed redis.conf tuning, especially regarding disk snapshots and eviction policies. Redis offers 8 eviction strategies, including volatile-lru and allkeys-lfu, whereas Memcached uses LRU exclusively.
When to choose what
- Choose Redis if: you need complex object caching, message queues (Pub/Sub, Stream), persistent session storage, or geospatial features.
- Choose Memcached if: you need the simplest, most stable string cache, plan to scale horizontally across hundreds of nodes, and have no data persistence requirements.
Cost / licensing
Memcached is distributed under the BSD license. As of 2024, Redis transitioned to RSALv2 and SSPLv1 licenses, restricting its use for cloud service providers, though the source code remains available for most developers. Open-source forks like Valkey maintain the original permissive licensing.
Ecosystem & integrations
Redis features a rich ecosystem of modules (RedisJSON, RediSearch) and native support in all modern frameworks. Memcached is supported by conservative stacks (PHP, legacy Java apps) and cloud providers as a standard, no-frills caching service.
Verdict
For modern applications, Redis is the de facto standard due to its flexibility and feature set. Memcached remains relevant for specific high-load caching scenarios where multithreading and minimal metadata overhead are critical.