Skip to content

Commit f57ae69

Browse files
committed
allow tls as scheme in DSN string for predis library
1 parent 1cc7c76 commit f57ae69

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

RedisConnectionFactory.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@ private function createRedis()
116116
*/
117117
private function parseDsn($dsn)
118118
{
119-
if (false === strpos($dsn, 'redis:')) {
120-
throw new \LogicException(sprintf('The given DSN "%s" is not supported. Must start with "redis:".', $dsn));
119+
$unsupportedError = 'The given DSN "%s" is not supported. Must start with "redis:".';
120+
121+
if ((false === strpos($dsn, 'redis:')) and (false === strpos($dsn, 'tls:'))) {
122+
throw new \LogicException(sprintf($unsupportedError, $dsn));
121123
}
122124

123125
if (false === $config = parse_url($dsn)) {
@@ -131,7 +133,12 @@ private function parseDsn($dsn)
131133
$config = array_replace($queryConfig, $config);
132134
}
133135

134-
unset($config['query'], $config['scheme']);
136+
//predis additionaly supports tls as scheme, but it must remain in the $config array
137+
if ($config['vendor']!='predis') {
138+
if ($config['scheme']!='redis') throw new \LogicException(sprintf($unsupportedError, $dsn));
139+
unset($config['scheme']);
140+
}
141+
unset($config['query']);
135142

136143
$config['lazy'] = empty($config['lazy']) ? false : true;
137144
$config['persisted'] = empty($config['persisted']) ? false : true;

0 commit comments

Comments
 (0)