Redis is used by Evolution API v2 as a caching system to optimize the application’s performance and speed. It can be configured to store temporary information and improve operational efficiency.

Installation and Configuration

Using Docker

The easiest and fastest way to set up Redis for Evolution API v2 is through Docker. Below are the instructions to configure Redis using Docker Compose.

Redis

To set up Redis via Docker, follow these steps:

  1. Download the docker-compose.yaml file for Redis available here.
  2. Navigate to the directory where the file was downloaded and run the command:
docker-compose up -d
  1. The Redis instance will be available at localhost on port 6379.

Environment Variables Configuration

After setting up Redis, define the following environment variables in your .env file:

# Enable Redis cache
CACHE_REDIS_ENABLED=true

# Redis connection URI
CACHE_REDIS_URI=redis://localhost:6379/6

# Prefix to differentiate data from different installations using the same Redis
CACHE_REDIS_PREFIX_KEY=evolution

# Enable to save connection information in Redis instead of the database
CACHE_REDIS_SAVE_INSTANCES=false

# Enable local cache
CACHE_LOCAL_ENABLED=false

Local Installation

If you prefer to set up Redis locally without using Docker, follow the instructions below:

Redis

  1. Install Redis on your machine. On Ubuntu-based systems, for example, you can use:
sudo apt-get update
sudo apt-get install redis-server
  1. Start the Redis service:
sudo service redis-server start
  1. Verify that Redis is running correctly with the command:
redis-cli ping

If everything is working correctly, you will see the response PONG.

Cache Configuration in Evolution API v2

After installing and configuring Redis, the next step is to configure caching in Evolution API v2 using environment variables. This will enable the API to use Redis to cache important data and improve the overall performance of the application.