A summary of the usage scenarios for memcached and Redis, based on the discussions of the great gods and the information I found online:
Compare the two:
- Redis provides data persistence, memcached no persistence;
- The data structure of Redis is richer than memcached and can accomplish things outside the scene;
- memcached single key limit in the 250b,value limit in 1mb;redis K, v are 512MB; Of course, these values can be modified in the source code;
- memcached data recovery based on the LRU algorithm, Redis provides a variety of recycling strategies (including LRU), but the expiration logic of the Redis recycling strategy is not dependent on the existence of a key to determine whether or not to expire. However, it is possible to determine whether the expiration is due to the TTL return value;
- Memcached uses multi-threading, and Redis uses single-threaded, IO-based multiplexing for high-speed access. So it can be understood that in extreme cases the throughput of memcached is greater than redis. Redis Hgetall Pit Everyone can go online to check.
Conclusion:
- Normal kv scene: Memcached, Redis all can.
- From the point of view of the single function module, recommend memcached, only do the cache one thing.
- In the case of a large kv length, a complex data structure (such as a piece of data that takes a value), and the need for persistence, Redis is more appropriate: But when using Redis, blocking a single request can cause a backlog of subsequent requests, which requires attention
Code base
- Memcached:
Https://github.com/memcached/memcached/blob/master
- Redis Code Library:
Https://github.com/antirez/redis
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Memcached and Redis comparison and application scenarios