Skip to content

Commit

Permalink
[9.x] Fix flushdb on cluster (#45544)
Browse files Browse the repository at this point in the history
* Fix flushdb on cluster

* Removes usages of `executeCommandOnNodes` method

Co-authored-by: Nuno Maduro <enunomaduro@gmail.com>
  • Loading branch information
driesvints and nunomaduro authored Jan 18, 2023
1 parent e4f05eb commit af11be5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Illuminate/Redis/Connections/PredisClusterConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Redis\Connections;

use Predis\Command\Redis\FLUSHDB;
use Predis\Command\ServerFlushDatabase;

class PredisClusterConnection extends PredisConnection
Expand All @@ -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()));
}
}
}

0 comments on commit af11be5

Please sign in to comment.