[Cache] fix Redis scheme detection

This commit is contained in:
Christian Flothmann 2017-06-03 09:31:39 +02:00
parent 89c3f5cccb
commit 61685c7106

View File

@ -90,6 +90,11 @@ class RedisAdapter extends AbstractAdapter
$params['dbindex'] = $m[1];
$params['path'] = substr($params['path'], 0, -strlen($m[0]));
}
if (isset($params['host'])) {
$scheme = 'tcp';
} else {
$scheme = 'unix';
}
$params += array(
'host' => isset($params['host']) ? $params['host'] : $params['path'],
'port' => isset($params['host']) ? 6379 : null,
@ -120,7 +125,7 @@ class RedisAdapter extends AbstractAdapter
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s', $e, $dsn));
}
} elseif (is_a($class, \Predis\Client::class, true)) {
$params['scheme'] = isset($params['host']) ? 'tcp' : 'unix';
$params['scheme'] = $scheme;
$params['database'] = $params['dbindex'] ?: null;
$params['password'] = $auth;
$redis = new $class((new Factory())->create($params));