Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6dc5fea

Browse files
committed
[Cache] Add TLS option for Redis connection
1 parent 44e98db commit 6dc5fea

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Symfony/Component/Cache/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
-----
66

77
* added support for connecting to Redis Sentinel clusters when using the Redis PHP extension
8+
* added TLS option for Redis connection
89

910
5.2.0
1011
-----

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ trait RedisTrait
4141
'redis_sentinel' => null,
4242
'dbindex' => 0,
4343
'failover' => 'none',
44+
'tls' => false,
4445
];
4546
private $redis;
4647
private $marshaller;
@@ -183,6 +184,12 @@ public static function createConnection($dsn, array $options = [])
183184
$host = $hosts[0]['host'] ?? $hosts[0]['path'];
184185
$port = $hosts[0]['port'] ?? null;
185186

187+
$tls = filter_var($params['tls'], \FILTER_VALIDATE_BOOLEAN);
188+
189+
if (true === $tls) {
190+
$host = 'tls://'.$host;
191+
}
192+
186193
if (isset($params['redis_sentinel'])) {
187194
$sentinel = new \RedisSentinel($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout']);
188195

0 commit comments

Comments
 (0)