Home >> Latest Articles >> Difference between Redis and Memcached

Difference between Redis and Memcached

Difference between Redis and Memcached - Redis and Memcached both are in-memory data stores. Redis is single-threaded, Memcached is multi-threaded
Q:- What is Redis?
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

Q:- What is in-memory Database?

The in-memory database is a database where it keeps the dataset in RAM. Means that for every interaction with the database, you will only access the Main memory; No DISK operations involved during this interaction. Hence the operation will be faster as it directly access main memory instead of any disk operation.

Q:- What is Redis Stand For?

Redis stands for REmote DIctionary Server.

Q:- What are the features of Redis?

Following are the features that redis offers to be used as a "real" data store instead of just a cache.

  1. Powerful data types and powerful commands:
    • Strings
    • Lists
    • Sets
    • Hashes
    • Bitmaps
    • HyperLogLogs
  2. Persistence to disk, by default.
  3. Transactions with optimistic locking (WATCH/MULTI/EXEC)
  4. Pub/sub. Extremely fast.
  5. Values up to 512MB in size (memcached limited to 1MB per key)
  6. Lua scripting (as of V2.6)
  7. Built in clustering (as of V3.0)
  8. Extremely fast at everything
Q:- What is Memcached?
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.

Q:- What is the difference between Redis and Memcached?
Features Redis Memcached
In Memory Yes Yes
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
Website redis.io memcached.org
You may also like - Database Interview Questions
Q:- List Some useful Redis Commands?

Following are some useful Redis commands:

  • redis-server: runs the Redis Server itself.
  • redis-sentinel: runs Redis Sentinel, a tool for monitoring and failover.
  • redis-cli: runs a command line interface utility to interact with Redis.
  • redis-cli --help: to check all the commands that can be used with redis-cli.
  • redis-benchmark: checks Redis performance.
Q:- How to check if Redis is Working?

We can use the redis-cli to send a command to it directly. To test that Redis is working properly. If everything is working well, we should get PONG as a reply in the shell.

redis-cli ping

//Output: PONG
You may also like - React Js Interview Questions
Q:- What is the default port for Redis?
6379
Q:- In which Language Redis has been Written?

Written in: ANSI C

Q:- List programming language supported by Redis?
  • C/C++
  • Go
  • Java
  • JavaScript
  • Node.js
  • Perl
  • PHP
  • Ruby
  • Scala
  • Swift
Full Stack Tutorials

Author | Blogger @FullStackTutorials | View all articles