From af11be582547f503d5ccf2b26bc81eaa833d8241 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 18 Jan 2023 17:39:23 +0100 Subject: [PATCH] [9.x] Fix flushdb on cluster (#45544) * Fix flushdb on cluster * Removes usages of `executeCommandOnNodes` method Co-authored-by: Nuno Maduro --- .../Redis/Connections/PredisClusterConnection.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Redis/Connections/PredisClusterConnection.php b/src/Illuminate/Redis/Connections/PredisClusterConnection.php index 6d07de16191d..dbf91dc46f77 100644 --- a/src/Illuminate/Redis/Connections/PredisClusterConnection.php +++ b/src/Illuminate/Redis/Connections/PredisClusterConnection.php @@ -2,6 +2,7 @@ namespace Illuminate\Redis\Connections; +use Predis\Command\Redis\FLUSHDB; use Predis\Command\ServerFlushDatabase; class PredisClusterConnection extends PredisConnection @@ -13,8 +14,12 @@ class PredisClusterConnection extends PredisConnection */ public function flushdb() { - $this->client->executeCommandOnNodes( - tap(new ServerFlushDatabase)->setArguments(func_get_args()) - ); + $command = class_exists(ServerFlushDatabase::class) + ? ServerFlushDatabase::class + : FLUSHDB::class; + + foreach ($this->client as $node) { + $node->executeCommand(tap(new $command)->setArguments(func_get_args())); + } } }