diff --git a/src/Illuminate/Redis/Connections/PhpRedisClusterConnection.php b/src/Illuminate/Redis/Connections/PhpRedisClusterConnection.php index e246fe6a1d1..7a9d2d0abc6 100644 --- a/src/Illuminate/Redis/Connections/PhpRedisClusterConnection.php +++ b/src/Illuminate/Redis/Connections/PhpRedisClusterConnection.php @@ -4,5 +4,21 @@ class PhpRedisClusterConnection extends PhpRedisConnection { - // + /** + * Flush the selected Redis database on all master nodes. + * + * @return mixed + */ + public function flushdb() + { + $arguments = func_get_args(); + + $async = strtoupper((string) $arguments[0] ?? null) === 'ASYNC'; + + foreach ($this->client->_masters() as $master) { + $async + ? $this->command('rawCommand', [$master, 'flushdb', 'async']) + : $this->command('flushdb', [$master]); + } + } } diff --git a/src/Illuminate/Redis/Connections/PhpRedisConnection.php b/src/Illuminate/Redis/Connections/PhpRedisConnection.php index ca9bd54457c..acf586bf6bd 100644 --- a/src/Illuminate/Redis/Connections/PhpRedisConnection.php +++ b/src/Illuminate/Redis/Connections/PhpRedisConnection.php @@ -7,7 +7,6 @@ use Illuminate\Support\Arr; use Illuminate\Support\Str; use Redis; -use RedisCluster; use RedisException; /** @@ -495,17 +494,17 @@ public function createSubscription($channels, Closure $callback, $method = 'subs /** * Flush the selected Redis database. * - * @return void + * @return mixed */ public function flushdb() { - if (! $this->client instanceof RedisCluster) { - return $this->command('flushdb'); - } + $arguments = func_get_args(); - foreach ($this->client->_masters() as $master) { - $this->client->flushDb($master); + if (strtoupper((string) $arguments[0] ?? null) === 'ASYNC') { + return $this->command('flushdb', [true]); } + + return $this->command('flushdb'); } /**