rhubarbgroup / redis-cache

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.
https://wordpress.org/plugins/redis-cache/
GNU General Public License v3.0
425 stars 148 forks source link

Command `_MASTERS` is not a registered Redis command when enable in cli #514

Closed Albvadi closed 5 months ago

Albvadi commented 5 months ago

Description

Hi, your worst nightmare here... :upside_down_face: According to https://github.com/rhubarbgroup/redis-cache/issues/512, I´m trying to enable Redis from command cli, and I get the following error:

[apache@myserver /opt/apache/htdocs/wordpress-site]$ php wp-cli.phar redis enable
Predis\ClientException: Command `_MASTERS` is not a registered Redis command. in /opt/apache/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Command/Factory.php:67
Stack trace:
#0 /opt/apache/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(313): Predis\Command\Factory->create()
#1 /opt/apache/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(304): Predis\Client->createCommand()
#2 /opt/apache/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/class-predis.php(164): Predis\Client->__call()
#3 /opt/apache/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/class-predis.php(198): Rhubarb\RedisCache\Predis->flush()
#4 /opt/apache/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/cli/class-commands.php(176): Rhubarb\RedisCache\Predis->flushOrFail()
#5 /opt/apache/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/cli/class-commands.php(63): Rhubarb\RedisCache\CLI\Commands->flush_redis()
#6 [internal function]: Rhubarb\RedisCache\CLI\Commands->enable()
#7 phar:///opt/apache/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func()
#8 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}()
#9 phar:///opt/apache/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func()
#10 phar:///opt/apache/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(431): WP_CLI\Dispatcher\Subcommand->invoke()
#11 phar:///opt/apache/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(454): WP_CLI\Runner->run_command()
#12 phar:///opt/apache/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1269): WP_CLI\Runner->run_command_and_exit()
#13 phar:///opt/apache/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#14 phar:///opt/apache/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process()
#15 phar:///opt/apache/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#16 phar:///opt/apache/htdocs/wordpress-site/wp-cli.phar/php/boot-phar.php(20): include('phar:///opt/htt...')
#17 /opt/apache/htdocs/wordpress-site/wp-cli.phar(4): include('phar:///opt/htt...')
#18 {main}
Error: Object cache could not be enabled. Redis server is unreachable: Command `_MASTERS` is not a registered Redis command.

If I enable this from Wordpress admin area, is enabled correctly.

Expected Behavior

Enable Redis from command cli

Actual Behavior

Exception

Steps to Reproduce

  1. Install new wordpress site and add the plugin
  2. Activate the plugin
  3. Enable fthe plugin from command cli

Environment

define('WP_REDIS_CLUSTER', [ 'tcp://redisint1.dev:6379?alias=redisint1', 'tcp://redisint2.dev:6379?alias=redisint2', 'tcp://redisint3.dev:6379?alias=redisint3' ]);

tillkruss commented 5 months ago

This will be fixed as part of #509.

In the meantime consider using phpredis instead of predis as the client.