REDIS, A cache database

REDIS, A cache database

If you are in the tech industry, working as a developer, or learning how to build a full-stack application. You must encounter the term REDIS.

Today, this article is based on the basics of REDIS.

What is REDIS?

Redis [Remote Dictionary Server] is a primary memory-based database that is used to store key-value pairs.

In easy words, Data is stored in the random access memory [RAM] of the server/system as key-value pairs.

In Redis, we can store multiple types of data such as JSON, string, numbers, etc but any data which we are going to be store much be in the form of string.

Why Redis?

Storing and retrieving any data from a traditional database can take some time. But sometimes, we need small data to be stored or retrieved immediately, that's where Redis comes into play.

Redis database is faster than other traditional databases because it is present in the ram of the server.

Installation of Redis (Linux)

To install Redis in Linux -

  1. Open the terminal.

  2. Enter this command "sudo apt install redis-server"

"redis-cli ping" is the command to check whether Redis is installed correctly or not, if you got PONG that means the installation is successful.

Commands to interact with Redis -

1. To open redis-client - "redis-cli"

2. To get all the keys of redis - "key *"

3. To add a new key-value pair in redis - "set name_of_key value_of_the_key"

4. To retrieve the existence key-value pair - "get name_of_key"

5. To delete a key-value pair - "del name_of_key"