Skip to content

Commit 635ff2f

Browse files
committed
Fixed #679
1 parent a946656 commit 635ff2f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/Phpfastcache/Drivers/Predis/Config.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace Phpfastcache\Drivers\Predis;
1818

1919
use Phpfastcache\Config\ConfigurationOption;
20+
use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException;
2021

2122
class Config extends ConfigurationOption
2223
{
@@ -60,6 +61,11 @@ class Config extends ConfigurationOption
6061
*/
6162
protected $persistent = false;
6263

64+
/**
65+
* @var string
66+
*/
67+
protected $scheme = 'unix';
68+
6369
/**
6470
* @return string
6571
*/
@@ -219,4 +225,26 @@ public function setPersistent(bool $persistent): Config
219225
$this->persistent = $persistent;
220226
return $this;
221227
}
228+
229+
/**
230+
* @return string
231+
*/
232+
public function getScheme(): string
233+
{
234+
return $this->scheme;
235+
}
236+
237+
/**
238+
* @param string $scheme
239+
* @return Config
240+
* @throws PhpfastcacheInvalidConfigurationException
241+
*/
242+
public function setScheme(string $scheme): Config
243+
{
244+
if(!\in_array($scheme, ['unix', 'tls'], true)){
245+
throw new PhpfastcacheInvalidConfigurationException('Invalid scheme: ' . $scheme);
246+
}
247+
$this->scheme = $scheme;
248+
return $this;
249+
}
222250
}

lib/Phpfastcache/Drivers/Predis/Driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function driverConnect(): bool
8181

8282
if (!empty($this->getConfig()->getPath())) {
8383
$this->instance = new PredisClient([
84-
'scheme' => 'unix',
84+
'scheme' => $this->getConfig()->getScheme(),
8585
'persistent' => $this->getConfig()->isPersistent(),
8686
'timeout' => $this->getConfig()->getTimeout(),
8787
'path' => $this->getConfig()->getPath(),

0 commit comments

Comments
 (0)