Skip to content

Commit 8954105

Browse files
committed
Add ability to specify password for the redis server
1 parent f85a62d commit 8954105

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/LaunchDarkly/Impl/Integrations/PHPRedisFeatureRequester.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public function __construct($baseUri, $sdkKey, $options)
3131
$this->_redisOptions = [
3232
"timeout" => $options['redis_timeout'] ?? 5,
3333
"host" => $options['redis_host'] ?? 'localhost',
34-
"port" => $options['redis_port'] ?? 6379
34+
"port" => $options['redis_port'] ?? 6379,
35+
"password" => $options['redis_password'] ?? null
3536
];
3637
}
3738
}
@@ -65,6 +66,12 @@ protected function getConnection()
6566
$this->_redisOptions["timeout"],
6667
'launchdarkly/php-server-sdk-redis-phpredis'
6768
);
69+
if (
70+
$this->_redisOptions['password'] !== null &&
71+
$this->_redisOptions['password' !== '']
72+
) {
73+
$redis->auth($this->_redisOptions['password']);
74+
}
6875
return $this->_redisInstance = $redis;
6976
}
7077
}

src/LaunchDarkly/Integrations/PHPRedis.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class PHPRedis
2424
* @param array $options Configuration settings (can also be passed in the main client configuration):
2525
* - `redis_host`: hostname of the Redis server; defaults to `localhost`
2626
* - `redis_port`: port of the Redis server; defaults to 6379
27+
* - `redis_password`: password to auth against the Redis server; optional
2728
* - `redis_timeout`: connection timeout in seconds; defaults to 5
2829
* - `redis_prefix`: a string to be prepended to all database keys; corresponds to the prefix
2930
* setting in ld-relay

0 commit comments

Comments
 (0)