mongodb and memcached are not in the same category. Mongodb is a document-based, non-relational database. Its advantage is that it has powerful query functions and can store massive amounts of data. There is no problem of who replaces whom between mongodb and memcached. Closer to memcached is redis. They are all in-memory databases, and the data is stored in memory directly through tcp
Mongodb and memcached are not in the same category. Mongodb is a document-based, non-relational database. Its advantage is that it has powerful query functions and can store massive amounts of data. There is no problem of who replaces whom between mongodb and memcached.
Closer to memcached is redis. They are all in-memory databases. The data is stored in the memory and directly accessed through TCP. The advantages are fast speed and high concurrency. The disadvantages are limited data types and weak query functions. They are generally used as caches. In our team’s projects, memcached was used at first, and later replaced by redis.
Compared to memcached:
1. Redis has a persistence mechanism that can persist data in memory to the hard disk regularly.
2. Redis has the binlog function, which can write all operations into the log. When redis fails, data can be recovered according to the binlog.
3. Redis supports virtual memory, which can limit the memory usage size. When the data exceeds the threshold, the least commonly used data in the memory is saved to the page file on the hard disk through an LRU-like algorithm.
4. Redis natively supports more data types and has greater room for imagination.
5. The consistent hashing mentioned by a friend earlier is used in redis sharding and is generally used when the load is very high and horizontal expansion is required. We haven’t used this feature yet. For general projects, a single machine is enough to support concurrency. Redis 3.0 will launch cluster with more powerful functions.
6. For more advantages of redis, please go to the official website to check.