Skip to content

Commit d0afa58

Browse files
taylorotwelldriesvints
authored andcommitted
auth with each master on flushdb
1 parent 82f8ddb commit d0afa58

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/Illuminate/Redis/Connections/PhpRedisConnection.php

+17-2
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,25 @@ class PhpRedisConnection extends Connection implements ConnectionContract
2121
*/
2222
protected $connector;
2323

24+
/**
25+
* The connection configuration array.
26+
*
27+
* @var array
28+
*/
29+
protected $config;
30+
2431
/**
2532
* Create a new PhpRedis connection.
2633
*
2734
* @param \Redis $client
2835
* @param callable|null $connector
36+
* @param array $config
2937
* @return void
3038
*/
31-
public function __construct($client, callable $connector = null)
39+
public function __construct($client, callable $connector = null, array $config = [])
3240
{
3341
$this->client = $client;
42+
$this->config = $config;
3443
$this->connector = $connector;
3544
}
3645

@@ -476,7 +485,13 @@ public function flushdb()
476485
}
477486

478487
foreach ($this->client->_masters() as [$host, $port]) {
479-
tap(new Redis)->connect($host, $port)->flushDb();
488+
$redis = tap(new Redis)->connect($host, $port);
489+
490+
if (isset($this->config['password']) && ! empty($this->config['password'])) {
491+
$redis->auth($this->config['password']);
492+
}
493+
494+
$redis->flushDb();
480495
}
481496
}
482497

src/Illuminate/Redis/Connectors/PhpRedisConnector.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function connect(array $config, array $options)
2828
));
2929
};
3030

31-
return new PhpRedisConnection($connector(), $connector);
31+
return new PhpRedisConnection($connector(), $connector, $config);
3232
}
3333

3434
/**

0 commit comments

Comments
 (0)