Help the world stop coronavirus! Stay home!

Prev Next

MongoDB / REDIS

Could not find what you were looking for? send us the question and we would be happy to answer your question.

What is Redis?

Redis is an open source in-memory data structure store which can be used as a database and/or a cache and message broker.

NoSQL Key/Value Store.

Supports Multiple data structures.

Built in Replication.

List few Redis Datatypes.

Redis supports,

  • Strings,
  • Lists,
  • Sets,
  • Sorted Sets,
  • Hashes,
  • Bitmaps,
  • Hyperlogs,
  • and Geospatial indexes.
Advantages of Redis.
  • Very Flexible.
  • No Schema and column names.
  • Very fast, can perform around 110K Set per second and 81K GETS per second.
  • Rich Datatype support,
  • command level Atomic Operation,
  • Caching & Disk Persistence.
What programming languages does Redis support?

REDIS supports most of the programming languages including Java, C#, Python, Scala, C++, R, PHP and many more.

Explain Replication in Redis.

Redis supports simple master to slave replication. When a relationship is established, data from the master is replicated to the slave.

Explain about REDIS security.

Redis is designed to be accessed by trusted clients.

REDIS can be restricted to certain interfaces.

Data encryption not supported and hence do not allow external access/internet exposure.

Expand REDIS.

Redis stands for REmote DIctionary Server.

In which language Redis is developed?

Redis is developed using ANSI C and mostly used for cache solution and session management. It creates unique keys for store values.

Difference between SET and MSET command in REDIS.

SET command creates one key-value pair while using MSET command, multiple key-value pairs can be created.

Explain LPUSH command in REDIS.

LPUSH inserts all the specified values at the head of the list stored at key. If the key does not exist, it is created as an empty list before performing the push operations. When key holds a value that is not a list, an error is returned.

Usage: LPUSH key value [value ...]

redis> LPUSH mylist "World"
(integer) 1
redis> LPUSH mylist "Hello"
(integer) 2
redis> LRANGE mylist 0 -1
1) "Hello"
2) "World"
redis> 
Limitations of REDIS.

REDIS is single threaded.

It has got limited client support for consistent hashing.

It has significant overhead for persistence.

It cannot be deployed widely.

REDIS is fast, but is it also durable?

No. Redis compromises with durability to enhance the speed. In Redis, in the case of system failure or crash, it writes to disk but may fall behind and lose the data which is not stored.

Difference between Memcached and REDIS.

Memcached.REDIS.
Memcached is multi-threaded. Redis is single threaded.
Memcached only does caching information. Redis does caching information and also supports persistence and replication.
Memcached supports the functionality of LRU (Least Recently Used) eviction of values.Redis does not support the functionality of LRU eviction of values.
In Memcached when they overflow memory, the one you have not used recently (LRU- Least Recently Used) will get deleted. 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.
Memcached supports CAS(Check And Set). It is useful for maintaining cache consistency. Redis does not support CAS ( Check And Set).

What is SADD command in REDIS?

Add the specified members to the set stored at key. Specified members that are already a member of this set are ignored. If key does not exist, a new set is created before adding the specified members.

An error is returned when the value stored at key is not a set.

Usage:

SADD key member [member ...]
Example:

redis> SADD myset "Hello"
(integer) 1
redis> SADD myset "World"
(integer) 1
redis> SADD myset "World"
(integer) 0
redis> SMEMBERS myset
1) "World"
2) "Hello"

Mention few LIST operations in REDIS.

LPUSH adds an element to the beginning of a list.

RPUSH add an element to the end of a list.

LPOP removes the first element from a list and returns it.

RPOP removes the last element from a list and returns it.

LLEN gets the length of a list.

LRANGE gets a range of elements from a list.

«
»
MuleESB

Comments & Discussions