Skip to content

Commit 9eefc94

Browse files
bernardwiesnerBernard Wiesnertillkrusstaylorotwell
authored
[8.x] Fix flushdb for predis cluster (#40446)
* Fix flushdb for predis cluster * move flushdb to PredisClusterConnection * add back flushdb * use `Predis\Client` iterator to get all nodes * return void otherwise it would return `Predis\Response\Status` * skip method all togehter * support `ASYNC` argument * Update PredisClusterConnection.php * fix typo * Update PredisClusterConnection.php Co-authored-by: Bernard Wiesner <[email protected]> Co-authored-by: Till Krüss <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
1 parent 9bdfdab commit 9eefc94

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

src/Illuminate/Redis/Connections/PredisClusterConnection.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
namespace Illuminate\Redis\Connections;
44

5+
use Predis\Command\ServerFlushDatabase;
6+
57
class PredisClusterConnection extends PredisConnection
68
{
7-
//
9+
/**
10+
* Flush the selected Redis database on all cluster nodes.
11+
*
12+
* @return void
13+
*/
14+
public function flushdb()
15+
{
16+
$this->client->executeCommandOnNodes(
17+
tap(new ServerFlushDatabase)->setArguments(func_get_args())
18+
);
19+
}
820
}

src/Illuminate/Redis/Connections/PredisConnection.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
use Closure;
66
use Illuminate\Contracts\Redis\Connection as ConnectionContract;
7-
use Predis\Command\ServerFlushDatabase;
8-
use Predis\Connection\Aggregate\ClusterInterface;
97

108
/**
119
* @mixin \Predis\Client
@@ -52,20 +50,4 @@ public function createSubscription($channels, Closure $callback, $method = 'subs
5250

5351
unset($loop);
5452
}
55-
56-
/**
57-
* Flush the selected Redis database.
58-
*
59-
* @return void
60-
*/
61-
public function flushdb()
62-
{
63-
if (! $this->client->getConnection() instanceof ClusterInterface) {
64-
return $this->command('flushdb');
65-
}
66-
67-
foreach ($this->getConnection() as $node) {
68-
$node->executeCommand(new ServerFlushDatabase);
69-
}
70-
}
7153
}

0 commit comments

Comments
 (0)