Skip to content

Commit fd46281

Browse files
authored
Merge pull request #409 from Geolim4/final
- Fixed redundant code in Predis driver - Added property PhpDoc to PathSeekerTrait
2 parents 17f7767 + 27c61ba commit fd46281

File tree

2 files changed

+9
-33
lines changed

2 files changed

+9
-33
lines changed

src/phpFastCache/Core/PathSeekerTrait.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
use phpFastCache\Exceptions\phpFastCacheDriverException;
1919
use phpFastCache\Util\Directory;
2020

21+
/**
22+
* Trait PathSeekerTrait
23+
* @package phpFastCache\Core\Pool\IO
24+
* @property array $config The configuration array passed via DriverBaseTrait
25+
*/
2126
trait PathSeekerTrait
2227
{
2328
/**

src/phpFastCache/Drivers/Predis/Driver.php

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -124,43 +124,14 @@ protected function driverClear()
124124
*/
125125
protected function driverConnect()
126126
{
127-
$server = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : [
127+
$config = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : [];
128+
129+
$this->instance = new PredisClient(array_merge([
128130
'host' => '127.0.0.1',
129131
'port' => '6379',
130132
'password' => '',
131133
'database' => '',
132-
];
133-
134-
$config = [
135-
'host' => $server[ 'host' ],
136-
];
137-
138-
$port = isset($server[ 'port' ]) ? $server[ 'port' ] : '';
139-
if ($port != '') {
140-
$config[ 'port' ] = $port;
141-
}
142-
143-
$password = isset($server[ 'password' ]) ? $server[ 'password' ] : '';
144-
if ($password != '') {
145-
$config[ 'password' ] = $password;
146-
}
147-
148-
$database = isset($server[ 'database' ]) ? $server[ 'database' ] : '';
149-
if ($database != '') {
150-
$config[ 'database' ] = $database;
151-
}
152-
153-
$timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : '';
154-
if ($timeout != '') {
155-
$config[ 'timeout' ] = $timeout;
156-
}
157-
158-
$read_write_timeout = isset($server[ 'read_write_timeout' ]) ? $server[ 'read_write_timeout' ] : '';
159-
if ($read_write_timeout != '') {
160-
$config[ 'read_write_timeout' ] = $read_write_timeout;
161-
}
162-
163-
$this->instance = new PredisClient($config);
134+
], $config));
164135

165136
return true;
166137
}

0 commit comments

Comments
 (0)