Caching: Differences and commonalities between Redis and Memcached

1. Common points

  • Both are memory-based databases, which are generally used as caches.
  • Both have expiration policies.
  • Both perform very well.

Two, the difference

  • Redis supports richer data types (supports more complex application scenarios). Redis not only supports simple k/v type data, but also provides
    storage of data structures such as list, set, zset, and hash. Memcached only supports the simplest k/v data type.

  • Redis supports data persistence. It can keep the data in the memory on the disk, and it can be loaded again for use when it is restarted. Memcached
    stores all the data in the memory.

  • Redis has a disaster recovery mechanism. Because the data in the cache can be persisted to disk.

  • Redis can put unused data on disk after the server memory is used up. However, Memcached will directly report an exception after the server memory is used up.

  • Memcached does not have a native cluster mode, and needs to rely on the client to write data to the cluster; but Redis currently supports the cluster
    mode natively.

  • Memcached is a multi-threaded, non-blocking IO multiplexing network model; Redis uses a single-threaded multiplexing IO multiplexing model. (Redis 6.0
    introduces multithreaded IO)

  • Redis supports the publish-subscribe model, Lua scripts, transactions and other functions, while Memcached does not. Also, Redis supports more programming languages.

  • The deletion strategy of Memcached expired data only uses lazy deletion, while Redis uses both lazy deletion and periodic deletion.

Guess you like

Origin blog.csdn.net/qq_29229567/article/details/127494459