1. Overview of Redis and Memcached
In this article, I tried to find differences between Redis and Memcached. Sometimes, we guy used some tech stack based on our personal feeling, ideally which should not be the case, but we do. Before choosing to anyone or before reaching out any conclusion, we should define some parameters, what is the demand of business? what we required and for why? what is our use case? I mean to say for how long this would be feasible, availability of resources ( manpower, server, environment, business context).
2. Key Differences between Redis And Memcached
- Redis also does cache information but has got additional features like persistence and replication while Memcached only does cache information.
- Redis does not support the functionality of LRU (least recently used) eviction of values, while Memcached supports the functionality of LRU (least recently used) eviction of values.
- In Redis you can set a time out on everything, when memory is full, it will look at three random keys and deletes the one which is closest to expiry, while, in Memcached when they overflow memory, the one you have not used recently (LRU- least recently used) will get deleted.
- Redis does not support CAS ( Check and Set). It is useful for maintaining cache consistency, Memcached supports CAS (Check and Set)
- Redis has got stronger data structures; it can handle strings, binary-safe strings, a list of binary-safe strings, sorted lists, etc., In Memcached, you have to serialize the objects or arrays in order to save them and to read them back you have to un-serialize them.
- Redis had a maximum of 2GB key length, Memcached had a maximum of 250 bytes length
Redis is single-threaded but executes 1 lac key per second, Memcached is a multi-threaded.
I hope you enjoyed this post of differences between distributed Redis and Memcached, and you can visit Architcture category and
Visit redis.io for Redis distributed Caching store.
Suggestions or comments are welcome to improve this post. cheers