Magento – Configuration Redis on Magento2 errors

cachemagento2redis

I already installed and tested Redis working properly on my server. But when I added Redis required settings cache in my app/etc/env.php then my Magento 2 displays blank page. I also tried to clean cache by running this command php bin/magento cache:clean and I got errors below

PHP Parse error: syntax error, unexpected
''automatic_cleaning_factor'' (T_CONSTANT_ENCAPSED_STRING), expecting
')' in app/etc/env.php on line 101

Below is my env.php config:

'cache' =>
  array (
    'frontend' =>
    array (
      'default' =>
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' =>
        array (
          'server' => '127.0.0.1',
          'port' => '6379',
          'persistent' => '',
          'database' => '0',
          'password' => '',
          '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',
          'use_lua' => '0',
        ),
      ),
      'page_cache' =>
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' =>
        array (
          'server' => '127.0.0.1',
          'port' => '6379',
          'persistent' => '',
          'database' => '1',
          'password' => '',
          'force_standalone' => '0',
          'connect_retries' => '1',
          'lifetimelimit' => '57600',
          'compress_data' => '0',
          'compress_tgs'  => '1',
          'compress_threshold' => '20480',
          'compression_lib' => 'gzip'
          'automatic_cleaning_factor' => '0',
        ),
      ),
    ),
  ),

I don't know reason why? Did I miss configuration setting in Magento or I had to disable memcached in Magento 2.

EDIT

PHP Fatal error: Uncaught exception 'CredisException' with message
'Connection to Redis failed after 2 failures.Last Error : (13)
Permission denied' in
/var/www/magento2/vendor/colinmollenhour/credis/Client.php:448\nStack
trace:\n#0
/var/www/magento2/vendor/colinmollenhour/credis/Client.php(444):
Credis_Client->connect()\n#1
/var/www/magento2/vendor/colinmollenhour/credis/Client.php(774):
Credis_Client->connect()\n#2
/var/www/magento2/vendor/colinmollenhour/credis/Client.php(604):
Credis_Client->__call('select', Array)\n#3
/var/www/magento2/vendor/colinmollenhour/cache-backend-redis/Cm/Cache/Backend/Redis.php(144):
Credis_Client->select(1)\n#4
/var/www/magento2/vendor/magento/zendframework1/library/Zend/Cache.php(153):
Cm_Cache_Backend_Redis->__construct(Array)\n#5
/var/www/magento2/vendor/magento/zendframework1/library/Zend/Cache.php(94):
Zend_Cache::_makeBackend('Cm_Cache_Backen…', Array, true, true)\n#6
/var/www/magento2/vendor/magento/framework/App/Cache/Frontend/Factory.php(156):
Zend_Cache::factory('Ma in
/var/www/magento2/vendor/colinmollenhour/credis/Client.php on line 448

Best Answer

You have a typo at the end of your config, you're missing a comma ',' after

'compression_lib' => 'gzip'
Related Topic