File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
lib/Phpfastcache/Drivers/Predis Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1717namespace Phpfastcache \Drivers \Predis ;
1818
1919use Phpfastcache \Config \ConfigurationOption ;
20+ use Phpfastcache \Exceptions \PhpfastcacheInvalidConfigurationException ;
2021
2122class 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}
Original file line number Diff line number Diff 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 (),
You can’t perform that action at this time.
0 commit comments