diff --git a/src/Illuminate/Redis/Connections/PhpRedisConnection.php b/src/Illuminate/Redis/Connections/PhpRedisConnection.php index 41d6607c97b1..0950ec97cdcb 100644 --- a/src/Illuminate/Redis/Connections/PhpRedisConnection.php +++ b/src/Illuminate/Redis/Connections/PhpRedisConnection.php @@ -21,16 +21,25 @@ class PhpRedisConnection extends Connection implements ConnectionContract */ protected $connector; + /** + * The connection configuration array. + * + * @var array + */ + protected $config; + /** * Create a new PhpRedis connection. * * @param \Redis $client * @param callable|null $connector + * @param array $config * @return void */ - public function __construct($client, callable $connector = null) + public function __construct($client, callable $connector = null, array $config = []) { $this->client = $client; + $this->config = $config; $this->connector = $connector; } @@ -476,7 +485,13 @@ public function flushdb() } foreach ($this->client->_masters() as [$host, $port]) { - tap(new Redis)->connect($host, $port)->flushDb(); + $redis = tap(new Redis)->connect($host, $port); + + if (isset($this->config['password']) && ! empty($this->config['password'])) { + $redis->auth($this->config['password']); + } + + $redis->flushDb(); } } diff --git a/src/Illuminate/Redis/Connectors/PhpRedisConnector.php b/src/Illuminate/Redis/Connectors/PhpRedisConnector.php index 38c353b9fca2..ebd6ee11d4ef 100644 --- a/src/Illuminate/Redis/Connectors/PhpRedisConnector.php +++ b/src/Illuminate/Redis/Connectors/PhpRedisConnector.php @@ -28,7 +28,7 @@ public function connect(array $config, array $options) )); }; - return new PhpRedisConnection($connector(), $connector); + return new PhpRedisConnection($connector(), $connector, $config); } /**