Difference between Redis and Memcached
Redis is an open source, in-memory data store, used as a database, cache and message broker.
Redis 5.0.3 is the latest stable version. Official Download Link
Redis stands for REmote DIctionary Server.
It is free, open source, high-performance, distributed memory object caching system
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.
Its simple design promotes quick deployment, ease of development and Its API is available for most popular languages.
|Process||Redis is single threaded||Memcached is multi-threaded|
|Data Persistence||Yes: Redis persist the in-memory data to a file system on regular intervals. During the failure of Redis node, the data can be restored from Redis Data file.||No: If you are using Memcached then data may lost with server restart and rebuilding cache is a costly process.|
|Replication||Yes: Redis supports master-slave replication.||No: Memcached does not supports replication.|
|Data Structures||Redis has got stronger data structures. it supports Strings, Lists, Sets, Hashes, Bitmaps etc.||it supports strings and object. 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.|
|LRU||No: LRU is not supported by Redis. When memory is full, it will look at three random keys and deletes the one which is closest to expiry.||Yes: Memcached supports LRU. When Memory is full, the one you have not used recently (LRU- least recently used) will get deleted.|
|CAS||No: Redis does not support CAS ( Check and Set). It is useful for maintaining cache consistency.||Yes: Memcached supports CAS (Check and Set)|
|Data Length||Redis had a maximum of 2GB key length||Memcached had a maximum of 250 bytes length|
|Pub/Sub Model||Yes - Redis supports Pub/Sub. Redis creates Publish and Subscribe channels where the Redis clients can subscribe to any channel to consume the data and any subscribed client to a channel can publish the data||No - Memcached doesn't supports Pub/Sub|
|Lua||Redis supports Lua scripting||Memcached doesn't supports Lua scripting|
|Transactions||Redis supports Transactions||Memcached doesn't supports Transactions|
|Geospatial support||Redis have Geospatial support||Memcached doesn't have Geospatial support|
You may also like - Database Interview Questions