|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* This file is part of phpFastCache. |
|
5
|
|
|
* |
|
6
|
|
|
* @license MIT License (MIT) |
|
7
|
|
|
* |
|
8
|
|
|
* For full copyright and license information, please see the docs/CREDITS.txt file. |
|
9
|
|
|
* |
|
10
|
|
|
* @author Khoa Bui (khoaofgod) <[email protected]> https://www.phpfastcache.com |
|
11
|
|
|
* @author Georges.L (Geolim4) <[email protected]> |
|
12
|
|
|
* |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
declare(strict_types=1); |
|
16
|
|
|
|
|
17
|
|
|
namespace Phpfastcache\Drivers\Predis; |
|
18
|
|
|
|
|
19
|
|
|
use Phpfastcache\Config\ConfigurationOption; |
|
20
|
|
|
use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; |
|
21
|
|
|
|
|
22
|
|
|
class Config extends ConfigurationOption |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $host = '127.0.0.1'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var int |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $port = 6379; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $password = ''; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var int |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $database = 0; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var \Predis\Client |
|
|
|
|
|
|
46
|
|
|
*/ |
|
47
|
|
|
protected $predisClient; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var string |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $optPrefix = ''; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var int |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $timeout = 5; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var bool |
|
61
|
|
|
*/ |
|
62
|
|
|
protected $persistent = false; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @var string |
|
66
|
|
|
*/ |
|
67
|
|
|
protected $scheme = 'unix'; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return string |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getHost(): string |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->host; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param string $host |
|
79
|
|
|
* @return Config |
|
80
|
|
|
*/ |
|
81
|
|
|
public function setHost(string $host): self |
|
82
|
|
|
{ |
|
83
|
|
|
$this->host = $host; |
|
84
|
|
|
return $this; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @return int |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getPort(): int |
|
91
|
|
|
{ |
|
92
|
|
|
return $this->port; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @param int $port |
|
97
|
|
|
* @return Config |
|
98
|
|
|
*/ |
|
99
|
|
|
public function setPort(int $port): self |
|
100
|
|
|
{ |
|
101
|
|
|
$this->port = $port; |
|
102
|
|
|
return $this; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @return null |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getPassword() |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->password; |
|
|
|
|
|
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @param null $password |
|
|
|
|
|
|
115
|
|
|
* @return self |
|
116
|
|
|
*/ |
|
117
|
|
|
public function setPassword(string $password): self |
|
118
|
|
|
{ |
|
119
|
|
|
$this->password = $password; |
|
120
|
|
|
return $this; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return int |
|
125
|
|
|
*/ |
|
126
|
|
|
public function getDatabase(): int |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->database; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @param int $database |
|
133
|
|
|
* @return Config |
|
134
|
|
|
*/ |
|
135
|
|
|
public function setDatabase(int $database): self |
|
136
|
|
|
{ |
|
137
|
|
|
$this->database = $database; |
|
138
|
|
|
return $this; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @return array |
|
143
|
|
|
*/ |
|
144
|
|
|
public function getPredisConfigArray(): array |
|
145
|
|
|
{ |
|
146
|
|
|
return [ |
|
147
|
|
|
'host' => $this->getHost(), |
|
148
|
|
|
'port' => $this->getPort(), |
|
149
|
|
|
'password' => $this->getPassword() ?: null, |
|
|
|
|
|
|
150
|
|
|
'database' => $this->getDatabase(), |
|
151
|
|
|
'timeout' => $this->getTimeout(), |
|
152
|
|
|
]; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @return \Predis\Client|null |
|
157
|
|
|
*/ |
|
158
|
|
|
public function getPredisClient() |
|
159
|
|
|
{ |
|
160
|
|
|
return $this->predisClient; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @param \Predis\Client $predisClient |null |
|
165
|
|
|
* @return Config |
|
166
|
|
|
*/ |
|
167
|
|
|
public function setPredisClient(\Predis\Client $predisClient = null): Config |
|
168
|
|
|
{ |
|
169
|
|
|
$this->predisClient = $predisClient; |
|
170
|
|
|
return $this; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* @return string |
|
175
|
|
|
* @since 7.0.2 |
|
176
|
|
|
*/ |
|
177
|
|
|
public function getOptPrefix(): string |
|
178
|
|
|
{ |
|
179
|
|
|
return $this->optPrefix; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* @param string $optPrefix |
|
184
|
|
|
* @return Config |
|
185
|
|
|
* @since 7.0.2 |
|
186
|
|
|
*/ |
|
187
|
|
|
public function setOptPrefix(string $optPrefix): Config |
|
188
|
|
|
{ |
|
189
|
|
|
$this->optPrefix = trim($optPrefix); |
|
190
|
|
|
return $this; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* @return int |
|
195
|
|
|
*/ |
|
196
|
|
|
public function getTimeout(): int |
|
197
|
|
|
{ |
|
198
|
|
|
return $this->timeout; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @param int $timeout |
|
203
|
|
|
* @return self |
|
204
|
|
|
*/ |
|
205
|
|
|
public function setTimeout(int $timeout): self |
|
206
|
|
|
{ |
|
207
|
|
|
$this->timeout = $timeout; |
|
208
|
|
|
return $this; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* @return bool |
|
213
|
|
|
*/ |
|
214
|
|
|
public function isPersistent(): bool |
|
215
|
|
|
{ |
|
216
|
|
|
return $this->persistent; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* @param bool $persistent |
|
221
|
|
|
* @return Config |
|
222
|
|
|
*/ |
|
223
|
|
|
public function setPersistent(bool $persistent): Config |
|
224
|
|
|
{ |
|
225
|
|
|
$this->persistent = $persistent; |
|
226
|
|
|
return $this; |
|
227
|
|
|
} |
|
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
|
|
|
} |
|
250
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths