📜  Redis与Memcached

📅  最后修改于: 2020-12-02 01:25:00             🧑  作者: Mango

Redis与Memcached

Comparison Index Memcached Redis
What is Memcached is in-memory key-value store, originally intended for caching purpose. Redis is in-memory data structure store, used as database, cache and message broker.
Description MemcacheD is easy, simply designed yet powerful. Its simple design promotes fast deployment, ease of exaggeration, and solves many problems related to large data caches. It has its inbuilt APIs which provide a very large hash table distributed across multiple machines & uses internal memory management to provide more efficiency. MemcacheD supports only String data type which are ideal for storing read-only data.
Memcached is a volatile in-memory key-value origin. It is multi-threaded and used primarily for caching objects.
Redis is an open source in-memory data structure store which also can be used as a database as well as caching. It supports almost all types of data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes through radius queries. Redis also can be used for messaging system used as pub/sub.
Primary database model Memcached follows Key-value store database model. Redis also follows Key-value store database model.
Developed By Memcached is developed by Danga Interactive. Redis is developed by Salvatore Sanfilippo.
Initial release Memcached was initially released in 2003. Redis was initially released in 2009.
Current release Memcached current version is 1.5.1, released in August 2017. Redis current version is 4.0.2, released in September 2017.
License Memcached is free and open source. Redis is also free and open source.
Cloud-based No No
Implementation language Memcached is implemented in C language. Redis is also implemented in C language.
Server operating systems FreeBSD
Linux
OS X
Unix
Windows
BSD
Linux
OS X
Windows
Supported programming languages .Net, C, C++, ColdFusion, Erlang, Java, Lisp, Lua, OCaml, Perl, PHP, Python, Ruby C,C#,C++, Clojure, Crystal, D, Dart, Elixir, Erlang, Fancy, Go, Haskell, Haxe, Java, JavaScript (Node.js), Lisp, Lua, MatLab, Objective-C, OCaml info, Perl, PHP, Prolog, Pure Data, Python, R, Rebol, Ruby, Rust, Scala, Scheme, Smalltalk, Tcl
Server-side scripts No Lua
Triggers No No
Partitioning methods None Sharding
Replication methods None Master-slave replication
MapReduce No No
Foreign keys No No
Transaction concepts No Optimistic locking, atomic execution of commands blocks and scripts
Concurrency Yes Yes
Durability No Yes
User concepts Yes Simple password-based access control
Installation Memcached is little bit complicated to install and run. Installing Redis is so much easier. No dependencies required.
Memory Usage MemcacheD is more memory efficient than Redis because it consumes comparatively less memory resources for metadata. Redis is more memory efficient, only after you use Redis hashes.
Persistence Memcached doesn’t use persistent data. While using Memcached, data might be lost with a restart and rebuilding cache is a costly process. Redis can handle persistent data. By default it syncs data to the disk at least every 2 seconds, offering optional & tuneable data persistence meant to bootstrap the cache after a planned shutdown or an unintentional failure. While we tend to regard the data in caches as volatile and transient, persisting data to disk can be quite valuable in caching scenarios.
Replication Memcached does not support replication. Redis supports master-slave replication.
Storage type MemcacheD stores variables in its memory and retrieves any information directly from the server memory instead of hitting the database again. Redis is like a database that resides in memory. It executes (reads and writes) a key/value pair from its database to return the result set. That’s why it is used by develepors for real-time metrics and analytics.
Execution Speed and Performance MemcacheD is very good to handle high traffic websites. It can read many information at a time and give you back at a great response time. Redis can neither handle high traffic on read nor heavy writes.
Data Structure MemcacheD uses only strings and integers in its data structure. So, everything you save can either be a string or an integer. It is complicated because with integers, the only data manipulation you can do is adding or subtracting them. If you need to save arrays or objects, you will have to serialize them first and then save them. To read them back, you will need to un-serialize. Redis has stronger data structures, which can handle not only strings integers but also binary-safe strings, lists of binary-safe strings, sets of binary-safe strings and sorted sets.
Key Length Memcached’s key length has a maximum of 250 bytes. Redis’ key-length has a maximum of 2GB.