Installing redis - Redis Server Fast storage of volatile data and Pub/Sub

Since the standard package repositories of CentOS do not include a Redis server, we will install the Extended Package for Enterprise Linux (EPEL) repository.

sudo yum -y install epel-release

To install the Redis server, install the redis package.

sudo yum -y install redis

Verify that the Redis server has been installed.

Let's check that the Redis server has been installed by using the systemctl status command.

sudo systemctl status redis

To start it, issue the following command

 sudo systemctl start redis
sudo systemctl start redis

Redis Client - redis-cli

When you install the Redis server, a command line application called redis-cli will also be installed to run Redis commands.

Uses of a Redis Server

There are two main uses for the Redis server.

Fast storage of volatile data

The Redis server can store volatile data at high speed.

Volatile data is data that is temporary and is scheduled to be erased.

Session information is erased after a certain period of time, and even if it is erased, the user is simply asked to start over from the login screen. Session information is volatile data.

Also, since the session must be retrieved with each HTTP request, Redis performs better than relational databases such as MariaDB.

Push Notification via Pub/Sub

Redis has a push notification mechanism called Pub/Sub, which makes it relatively easy to implement real-time chat and real-time updates.

Redis has a Web API, so if your Web framework supports non-blocking, you can access Redis with non-blocking HTTP requests.

For a sample of real-time chat using Mojolicious, WebSocket, and Redis, please refer to the following

Associated Information