Set up Redis service

Redis is an optional, backend cache solution that replaces the Zend Framework Zend_Cache_Backend_File, which Adobe Commerce uses by default.

See Configure Redis in the Configuration guide.

Use the following instructions for service setup on Pro Integration environments and Starter environments, including the master branch.

NOTE
Submit an Adobe Commerce Support ticket to change the service configuration on Pro Production and Staging environments.

To enable Redis:

  1. Add the required name and type to the .magento/services.yaml file.

    code language-yaml
    myredis:
        type: redis:<version>
    

    To provide your own Redis configuration, add a core_config key in your .magento/services.yaml file:

    code language-yaml
    cache:
        type: redis:<version>
    
  2. Configure the relationships in the .magento.app.yaml file.

    code language-yaml
    runtime:
        extensions:
            - redis
    
    relationships:
        redis: "redis:redis"
    
  3. Add, commit, and push your code changes.

    code language-bash
    git add .magento/services.yaml .magento.app.yaml && git commit -m "Enable redis service" && git push origin <branch-name>
    
  4. Verify the service relationships.

TIP
After initial service setup, you can change the software version for an installed service by updating the services.yaml and .magento.app.yaml configuration files. See Change service version for guidance on upgrading or downgrading a service.

Using the Redis CLI

Assuming your Redis relationship is named redis, you can access it using the redis-cli tool.

  1. Use SSH to connect to the integration environment with Redis installed and configured.

  2. Open an SSH tunnel to a host.

    code language-bash
    redis-cli -h redis.internal
    

Get installed Redis version

Use the following command to get the Redis version installed on an integration environment:

redis-cli -h redis.internal info | grep version

Sample response:

redis_version:7.0.5
gcc_version:8.3.0

Redis on Pro staging and production

To get the Redis version installed on a Staging or Production environment, use the redis-server command:

redis-server -v
Redis server v=7.0.5 ...

Use the following command to get the Redis configuration installed on a Pro Staging or Production environment:

echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | json_pp

Sample response:

"redis" : [
    {
        "cluster" : "project-master-123abc4",
        "fragment" : null,
        "host" : "redis.internal",
        "host_mapped" : false,
        "hostname" : "oblahblahblahblahe.redis.service._.magentosite.cloud",
        "ip" : "169.254.10.10",
        "password" : null,
        "path" : null,
        "port" : 6379,
        "public" : false,
        "query" : {},
        "rel" : "redis",
        "scheme" : "redis",
        "service" : "redis",
        "type" : "redis:7.0.5",
        "username" : null
    }
]

Troubleshooting Redis

See the following Adobe Commerce Support articles for help with troubleshooting Redis problems:

05f2f56e-ac5d-4931-8cdb-764e60e16f26