Configure Redis Cache for Magento 2 on HYPERNODE

In this step, we are going to configure Redis on Magento 2. You need to add Redis configuration in Magento2_ROOT_Directory > app > etc > env.php file. In this env.php file, you would find a large PHP array with different settings and configuration. We would add the following configuration at the end of this file right before “);” which is the ending parenthesis of PHP array:



'cache' =>
  array (
    'frontend' =>
    array (
      'default' =>
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' =>
        array (
          'server' => 'redismaster',
          'port' => '6379',
          'persistent' => '',
          'database' => '0',
          'force_standalone' => '0',
          'connect_retries' => '1',
          'read_timeout' => '10',
          'automatic_cleaning_factor' => '0',
          'compress_data' => '1',
          'compress_tags' => '1',
          'compress_threshold' => '20480',
          'compression_lib' => 'gzip',
        ),
      ),
      'page_cache' =>
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' =>
        array (
          'server' => 'redismaster',
          'port' => '6379',
          'persistent' => '',
          'database' => '1',
          'force_standalone' => '0',
          'connect_retries' => '1',
          'read_timeout' => '10',
          'automatic_cleaning_factor' => '0',
          'compress_data' => '0',
          'compress_tags' => '1',
          'compress_threshold' => '20480',
          'compression_lib' => 'gzip',
        ),
      ),
    ),
  ),
Save your env.php file and clear Magento 2 cache with php bin/magento cache:flush command.

Monitor & Verify Redis Cache

To verify whether you have correctly configured Redis cache on Magento 2, you can use the following commands in the SSH terminal:

Type redis-cli monitor and refresh your site, you will see an output on your screen.
Type redis-cli ping and you’ll get a reply of ‘PONG’ which means everything is looking good.
Type php -m | grep redis by which you’ll see ‘redis’ in reply, which confirms that the PHP Redis Extension is ready to go.
Also, if you need to clear Redis cache, simple type redis-cli FLUSHALL and an OK reply will confirm that your cache has been cleared successfully.

Hebt u meer vragen? Een aanvraag indienen

Opmerkingen

Mogelijk gemaakt door Zendesk