Set up the redis service

Redis is an optional backend cache solution to replace Zend_Cache_Backend_File, which is used in Magento 2 by default.

More information about Redis

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


The format exposed in the $MAGENTO_CLOUD_RELATIONSHIPS follows:

    "redis": [
            "host": "",
            "scheme": "redis",
            "port": 6379

Usage example

In your .magento/services.yaml:

    type: redis:3.0

You can also use the following:

    type: redis:3.0

In your, configure the relationship and enable the PHP redis extension if you are using PHP:

        - redis

    redis: "myredis:redis"

You can then use the service in a configuration file of your application as follows:

    $relationships = json_decode(base64_decode(getenv('MAGENTO_CLOUD_RELATIONSHIPS')), true);

    foreach ($relationships['redis'] as $endpoint) {
        $container->setParameter('redis_host', $endpoint['host']);
        $container->setParameter('redis_port', $endpoint['port']);

Using redis-cli to access your Redis service

Assuming your Redis relationship is named redis, you can access it by opening an SSH tunnel to a host named redis.internal using the redis-cli tool.

redis-cli -h redis.internal