Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Fix flushdb for predis cluster #40446

Merged
merged 10 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Illuminate/Redis/Connections/PredisClusterConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@

namespace Illuminate\Redis\Connections;

use Predis\Command\ServerFlushDatabase;

class PredisClusterConnection extends PredisConnection
{
//
/**
* Flush the selected Redis database.
*
* @return void
*/
public function flushdb()
{
foreach ($this->client->getIterator() as $node) {
$node->executeCommand(new ServerFlushDatabase);
tillkruss marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
10 changes: 1 addition & 9 deletions src/Illuminate/Redis/Connections/PredisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use Closure;
use Illuminate\Contracts\Redis\Connection as ConnectionContract;
use Predis\Command\ServerFlushDatabase;
use Predis\Connection\Aggregate\ClusterInterface;

/**
* @mixin \Predis\Client
Expand Down Expand Up @@ -60,12 +58,6 @@ public function createSubscription($channels, Closure $callback, $method = 'subs
*/
public function flushdb()
{
if (! $this->client->getConnection() instanceof ClusterInterface) {
return $this->command('flushdb');
}

foreach ($this->getConnection() as $node) {
$node->executeCommand(new ServerFlushDatabase);
}
return $this->command('flushdb');
}
bernardwiesner marked this conversation as resolved.
Show resolved Hide resolved
}