Skip to content

Commit

Permalink
Allow empty Redis config
Browse files Browse the repository at this point in the history
When Redis config is empty, use defaults.
However when a Redis cluster config is specified, the "seeds" attribute
is mandatory.

Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 committed Jul 23, 2021
1 parent 9797674 commit 41ddbec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/private/RedisFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ private function create() {
? $this->config->getValue('redis.cluster', [])
: $this->config->getValue('redis', []);

if (empty($config)) {
throw new \Exception('Redis config is empty');
}

if ($isCluster && !class_exists('RedisCluster')) {
throw new \Exception('Redis Cluster support is not available');
}
Expand Down Expand Up @@ -86,6 +82,10 @@ private function create() {

// cluster config
if ($isCluster) {
if (!isset($config['seeds'])) {
throw new \Exception('Redis cluster config is missing the "seeds" attribute');
}

// Support for older phpredis versions not supporting connectionParameters
if ($connectionParameters !== null) {
$this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, false, $auth, $connectionParameters);
Expand Down

0 comments on commit 41ddbec

Please sign in to comment.