Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Yii Framework 2 redis extension Change Log
------------------------

- Bug #247: `Cache::getValue()` now returns `false` in case of missing key (rhertogh)
- Enh #249 Added support to set the redis scheme to tls. Add to configuration: `'scheme' => 'tls'` (tychovbh)


2.0.17 January 11, 2022
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,18 @@ return [
],
];
```

**Configuring The Connection Scheme**

By default, Redis will use the tcp scheme when connecting to your Redis server; however, you may use TLS / SSL encryption by specifying a scheme configuration option in your application configuration:
```php
return [
//....
'components' => [
'redis' => [
//....
'scheme' => 'tls'
]
]
];
```
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,10 @@
"type": "composer",
"url": "https://asset-packagist.org"
}
]
],
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
}
}
}
7 changes: 6 additions & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ class Connection extends Component
* If [[unixSocket]] is specified, hostname and [[port]] will be ignored.
*/
public $hostname = 'localhost';
/**
* @var string the connection scheme used for connecting to the redis server. Defaults to 'tcp'.
* @since 2.0.18
*/
public $scheme = 'tcp';
/**
* @var string if the query gets redirected, use this as the temporary new hostname
* @since 2.0.11
Expand Down Expand Up @@ -593,7 +598,7 @@ public function getConnectionString()
return 'unix://' . $this->unixSocket;
}

return 'tcp://' . ($this->redirectConnectionString ?: "$this->hostname:$this->port");
return $this->scheme . '://' . ($this->redirectConnectionString ?: "$this->hostname:$this->port");
}

/**
Expand Down