Skip to content

A Magento 2 module to integrate Relay.

License

Notifications You must be signed in to change notification settings

cachewerk/magento-relay

Repository files navigation

Magento Relay

Installation

First, install Relay as a PHP extension for your CLI and FPM environments.

Next, install the Magento module:

composer require cachewerk/magento-relay

Finally, activate the module. Relay won't be used until you configure Magento to do so.

bin/magento module:enable CacheWerk_Relay
bin/magento setup:upgrade

Configuration

If you're not using Magento's Redis integration for caching and sessions, we recommend configuring and testing that first.

Sessions

To use Relay as the session backend, simply set session.redis.client to relay in your app/etc/env.php:

'session' => [
    'save' => 'redis',
    'redis' => [
+       'client' => 'relay',
        'host' => '127.0.0.1',
        'port' => 6379,
        'database' => 2,
        // ...
    ]
],

Cache Backends

Relay can be used for any Redis-enabled cache backend in your app/etc/env.php:

'cache' => [
    'frontend' => [
        'default' => [
            'id_prefix' => '5ac_',
-           'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis',
+           'backend' => 'CacheWerk\\Relay\\Cache\\Backend\\Relay',
            'backend_options' => [
                'server' => '127.0.0.1',
                'port' => 6379,
                'database' => 0,
                // ...
            ]
        ],
        'page_cache' => [
            'id_prefix' => '5ac_',
-           'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis',
+           'backend' => 'CacheWerk\\Relay\\Cache\\Backend\\Relay',
            'backend_options' => [
                'server' => '127.0.0.1',
                'port' => 6379,
                'database' => 1,
                // ...
            ]
        ]
    ],
],