DEV Community

SriSarvesh
SriSarvesh

Posted on

Redis

  1. The open-source, in-memory data store is used by millions of developers as a database, cache, streaming engine, and message broker(It can be used as a queue manager for our jobs).

  2. But if the data that we are trying to store is bigger than memory then we need to move it to the secondary storage and then execute which makes it useless of the Redis concept.

  3. So it is better to have data in the Redis smaller than the memory. So that we can perform all kinds of computations easily.

  4. And also this Redis should be treated like NoSQL. And this follows a client-server architecture and we try to connect to the server(which runs as a process at port 6379(localhost) ) to perform the required things we wanna perform.

  5. And Redis comes with cli(client) using which we can perform the required operations on the server. And also there is a UI-based client which is a Redis Desktop Manager.
    Using

sudo snap install redis-desktop-manager

We install the GUI-based Redis-desktop-manager.

  1. So after installing the GUI-based app we can connect to the local connection by giving a sample name. And then we will be able to see various databases and they are index based instead of names.

  2. And by clicking each of those db(index) we can insert multiple key-value pairs. And for each key, there will be a value and we can set up TTL(Time to live in seconds) which means the duration for how long this key-Value will be stored in the Redis DB. ( for ex: -1 (then it will be stored for ever). And after the time is over the key value will be removed.

  3. So we have this feature because we want to cache the data only for a certain period of time. So this can be used when we want to cache the result of an External API for a certain period of time and then later we try to remove it from the cache and again perform the API call.

  4. And also there is a concept of Publisher and subscriber concept in Redis. So where there will be a publisher and many subscribers to it and when the publisher publishes certain things then all the subscribers get the
    message/content/alerting/push messages to the people.

  5. And also Redis provides the transaction even though we use it as a NoSQL database. And also it provides ACL(Access control list). And also a certain user can establish a connection to this database if they have a valid username and password.

  6. So we use Redis as a JOB queue for handling Asynchronous JOB where the Redis will be used as Publication and Subscriber server for sending push messages to the client (one by one)after the client has made a request to the server. And also we are going to use it as a cache.

Top comments (0)