Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
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'
]
]
];
```
6 changes: 5 additions & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ 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'.
*/
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 +597,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