cancel
Showing results for 
Search instead for 
Did you mean: 

Disabling Redis cache from command line ?

Disabling Redis cache from command line ?

Hi setup Magento 2.2.2 with default, page cache and session cache set to redis caching using below 3 commands. But what's the proper way to revert them to their defaults so I can benchmark the difference ?

 

What are the valid options available for

  • --cache-backend
  • --page-cache
  • --session-save

to switch back to defaults ?

 

# setup default, full page and session based redis caching in redis databases 12, 13 and 14 respectively instead of default
redisserver=127.0.0.1

# lz4 or gzip
compresstype=lz4
php $WEBROOT/bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=$redisserver --cache-backend-redis-db=12

php $WEBROOT/bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=$redisserver --page-cache-redis-db=13 --page-cache-redis-compress-data=$compresstype

php $WEBROOT/bin/magento setup:config:set --session-save=redis --session-save-redis-host=$redisserver --session-save-redis-log-level=3 --session-save-redis-db=14 --session-save-redis-compression-lib=$compresstype

 

 

7 REPLIES 7

Re: Disabling Redis cache from command line ?

I am not aware about command lin using disable redis cache but you can disable redis cache by file system,

Just go to app/etc/env.php file

You need to comment our cache array of redis section from env.php file and flush magento caches remove your redis cache from system

 

 'cache' => 
    array (
      'frontend' => 
      array (
        'default' => 
        array (
          'backend' => 'Cm_Cache_Backend_Redis',
          'backend_options' => 
          array (
            'server' => '/var/run/redis.sock',
            'database' => '0',
            'port' => '0',
          ),
        ),
        'page_cache' => 
        array (
          'backend' => 'Cm_Cache_Backend_Redis',
          'backend_options' => 
          array (
            'server' => '/var/run/redis.sock',
            'port' => '0',
            'database' => '1',
            'compress_data' => '0',
          ),
        ),
      ),
    ),

Comment out above line in env.php file

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Disabling Redis cache from command line ?

Thanks I know about manual method for removing page and default redis caching from env.php but was wondering if there is a cmd line method too.

 

The official docs do list cmd line to set it up but not to remove it which is confusing I want to automate this and script it for benchmarking etc. Maybe can just make a copy of env.php for non-redis and one copy of env.php for redis to swap them when needed ? But cmd line would be nice. Surprised not many Magento guides online cover the cmd line method at all !

Re: Disabling Redis cache from command line ?

Yes, you can only done this by manual operation.

 

you need to remove its entry from env.php

 

You can restart , stop and start redis-server by following command which might you know already !

 

/etc/init.d/redis-server restart

 

or stop/start it:

 

/etc/init.d/redis-server stop
/etc/init.d/redis-server start


But to make it default , As of Now there is no option at command line , you need to do it manually only!!

 

if issue solved,Click Kudos & Accept as Solution

Re: Disabling Redis cache from command line ?

Thanks for now I decided to create separate env.php config files for redis cache and without and swap them for automated benchmarks. But would be nice to have command line method of switching back to non-redis methods though Smiley Happy

 

the diff

 

diff -u app/etc/env.php app/etc/env.php.redisset
--- app/etc/env.php     2018-03-13 13:25:50.794181470 +0000
+++ app/etc/env.php.redisset    2018-03-13 05:30:56.948206383 +0000
@@ -37,7 +37,28 @@
   'MAGE_MODE' => 'production',
   'session' => 
   array (
-    'save' => 'files',
+    'save' => 'redis',
+    'redis' => 
+    array (
+      'host' => '127.0.0.1',
+      'port' => '6379',
+      'password' => '',
+      'timeout' => '2.5',
+      'persistent_identifier' => '',
+      'database' => '14',
+      'compression_threshold' => '2048',
+      'compression_library' => 'lz4',
+      'log_level' => '3',
+      'max_concurrency' => '4',
+      'break_after_frontend' => '60',
+      'break_after_adminhtml' => '60',
+      'first_lifetime' => '600',
+      'bot_first_lifetime' => '60',
+      'bot_lifetime' => '7200',
+      'disable_locking' => '0',
+      'min_lifetime' => '60',
+      'max_lifetime' => '2592000',
+    ),
   ),
   'cache_types' => 
   array (
@@ -60,6 +81,33 @@
   array (
     'date' => 'Sun, 11 Mar 2018 20:40:12 +0000',
   ),
+  'cache' => 
+  array (
+    'frontend' => 
+    array (
+      'default' => 
+      array (
+        'backend' => 'Cm_Cache_Backend_Redis',
+        'backend_options' => 
+        array (
+          'server' => '127.0.0.1',
+          'database' => '12',
+          'port' => '6379',
+        ),
+      ),
+      'page_cache' => 
+      array (
+        'backend' => 'Cm_Cache_Backend_Redis',
+        'backend_options' => 
+        array (
+          'server' => '127.0.0.1',
+          'database' => '13',
+          'port' => '6379',
+          'compress_data' => 'lz4',
+        ),
+      ),
+    ),
+  ),
   'system' => 
   array (
     'default' => 

 

Re: Disabling Redis cache from command line ?

Yes agree with your concept that might work as of now Smiley Happy

 

but yes you can add same thing in feature request ,might be it will consider it next release

if issue solved,Click Kudos & Accept as Solution

Re: Disabling Redis cache from command line ?

By Default, there are not any command line method to disable your redis cache in system. You can just disable by using app/etc/env.php file to comment your cache code and flush magento cache. There are not any command line method given by Redis to disable cache using command line.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Disabling Redis cache from command line ?

This comes a bit late, but for the people who end up here via search engines:

 

You can now use magerun2 (at least version 4.9.0) to do this, via these 4 commands:

magerun2.phar config:env:delete cache.frontend.default.backend
magerun2.phar config:env:delete cache.frontend.default.backend_options
magerun2.phar config:env:delete cache.frontend.page_cache.backend
magerun2.phar config:env:delete cache.frontend.page_cache.backend_options