Set up Redis service

Redis is an optional, backend cache solution that replaces the Zend Framework Zend_Cache_Backend_File, which is used in Magento 2 by default.

We support Redis versions 2.8 and 3.0. Redis 3.0 supports up to 64 different databases per instance of the service, while 2.8 allows for only a single database. See Configure Redis.

Add Redis in configuration files

To enable Redis, add your installed version and allocated disk space in MB to .magento/services.yaml file:

myredis:
    type: redis:3.0

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

cache:
    type: redis:3.0

To configure relationships for an environment variable in your .magento.app.yaml file:

runtime:
    extensions:
        - redis

relationships:
    redis: "myredis:redis"

Merge and deploy the code to set the configurations for Redis. For information on how these changes affect your environments, see services.yaml.

Verify environment-related relationships

We use the Magento Commerce (Cloud) environment variable $MAGENTO_CLOUD_RELATIONSHIPS, a JSON object, to retrieve environment-related relationships.

To verify this information used for configurations and settings:

  1. Use SSH to connect to the Integration environment with Redis installed and configured.
  2. Create pretty-print connection information for Redis.

    php -r 'print_r(json_decode(base64_decode($_ENV["MAGENTO_CLOUD_RELATIONSHIPS"])));'
    

    The response includes all relationships for services and configuration data for that environment, similar to the following for Redis:

    {
        "redis": [
            {
                "host": "192.0.2.55",
                "scheme": "redis",
                "port": 6379
            }
        ]
    }
    

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 RabbitMQ installed and configured.
  2. Open an SSH tunnel to a host.

    redis-cli -h redis.internal