paragraph break

Redis and Memcached are popular, open-source, in-memory data stores cache engines, while they provide different advantages in similar use case, this article is meant to make a note of the differences between these engines.

Memcached is designed for simplicity while Redis offers a rich set of features that make it effective for a wide range of use cases.

  • The popularity compare with Redis and Memcached: The popularity compare with Redis and Memcached

    Source: Google Trends

Similarities between Redis and Memcached

There are many similarities between Memcached and Redis.

  • Easy to use
    Both Redis and Memcached are syntactically easy to use and require a minimal amount of code to integrate into your application.
  • In-memory store, fast response, sub-millisecond latency
  • Support for concurrent manipulation of data



  • Atomicity

    • Redis supports the concept of the transaction through commands like MULTI, WATCH, EXEC, which could execute a batch of commands atomically.


    • Memcached has only incr and decr commands.
  • Memory usage: Only Redis is capable of reclaiming memory usage.
    • Redis: Setting a max size is up to you. Redis will never use more than it has to and will give you back memory it is no longer using.
    • Memcached: you could flush the database, but it would still use the full chunk of RAM you configured it with.
  • Data persistence (Disk I/O dumping)
    • Redis has very configurable persistence.
      • Snapshot
      • AOF persistence log
    • Memcached:
      • Memcached has no mechanisms for dumping to disk without 3rd party tools.
      • RAM only. Everything Memcached does is an attempt to guarantee latency and speed. If you have to sometimes hit the disk, that’s no longer true (ref).
  • Memcached is multithreaded architecture
    • Memcached is multithreaded, it can make use of multiple processing cores.
    • Redis has lots of features and is very fast, but completely limited to one core as it is based on an event loop.


The use case suits for Memcached

  • Simple model
  • Use multiple threads to execute multi-node programs for large cache size
  • Aim for scalability of nodes
  • Mean to distribute data to different nodes (using memory amount servers more efficiently)

The use case suits for Redis

  • Dealing with complicated data types (Supported data types are strings, hashes, lists, sets and sorted sets, bit arrays, hyperloglogs and geospatial indexes)
  • Sorting data in-memory
  • Separate data into multiple points of reading and writing (Replication)
  • Automated error repair
  • Backup and restore data
  • Advanced data structures

    In addition to strings, Redis supports list, sets, sorted sets, hashes, bit arrays, and hyperloglogs. Applications can use their more advanced data structures to support a variety of use cases. (e.g. use Redis Sorted Sets to implement real-time rank sorting)

Comparison Chart

DescriptionIn-memory key-value store, originally intended for cachingIn-memory data structure store, used as database, cache and message broker
Primary database modelkey-value storeKey-value store
Secondary database models Document store
Graph DBMS
Search engine
Time Series DBMS
Partitioning methods
(Methods for store different data on different nodes)
YesCluster mode
Transaction concepts
(Support to ensure data integrity after non-atomic manipulations of data)
NoOptimistic locking, atomic execution of commands blocks and scripts
Access controlUsing SASL (Simple Authentication and Security Layer) protocolSimple password-based access control (Access control lists and SSL are available in the commercial version)
Predefined data typeNostrings, hashes, lists, sets and sorted sets, bit arrays, hyperloglogs and geospatial indexes
Multithreaded architectureYesNo
Data persistenceNoSnapshot
AOF persistence log
Backup and restoreNoYes
Reclaim memoryNoYes
High availability


paragraph break


⤧  Previous post Memcached notes - Start Memcached ⤧  Next post How to install Docker on Ubuntu 20.04