@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | return; |
28 | 28 | } else if (strpos($entity, 'Psr\Cache') === 0) { |
29 | 29 | trigger_error('If you cannot use <b>composer</b>, you have to include manually the Psr\\Cache interfaces.<br />See: https://github.com/php-fig/cache/tree/master/src<br /> Called ' . $entity, |
30 | - E_USER_ERROR); |
|
30 | + E_USER_ERROR); |
|
31 | 31 | |
32 | 32 | return; |
33 | 33 | } |
@@ -42,5 +42,5 @@ discard block |
||
42 | 42 | |
43 | 43 | if (class_exists('Composer\Autoload\ClassLoader')) { |
44 | 44 | trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
45 | - E_USER_WARNING); |
|
45 | + E_USER_WARNING); |
|
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -27,7 +27,7 @@ |
||
27 | 27 | return true; |
28 | 28 | } else if (constant($CONSTANT_NAME) !== $driverName) { |
29 | 29 | trigger_error('Memcache collision detected, you used both Memcache and Memcached driver in your script, this may leads to unexpected behaviours', |
30 | - E_USER_WARNING); |
|
30 | + E_USER_WARNING); |
|
31 | 31 | |
32 | 32 | return false; |
33 | 33 | } |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | protected static function cleanFileName($filename) |
161 | 161 | { |
162 | 162 | $regex = [ |
163 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
164 | - '/\.$/', |
|
165 | - '/^\./', |
|
163 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
164 | + '/\.$/', |
|
165 | + '/^\./', |
|
166 | 166 | ]; |
167 | 167 | $replace = ['-', '', '']; |
168 | 168 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | chmod($path, 0777); |
183 | 183 | } catch (phpFastCacheDriverException $e) { |
184 | 184 | throw new phpFastCacheDriverException('PLEASE CHMOD ' . $path . ' - 0777 OR ANY WRITABLE PERMISSION!', |
185 | - 92); |
|
185 | + 92); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | $key = $key[ 0 ]; |
254 | 254 | } |
255 | 255 | $content[ $key ] = [ |
256 | - 'size' => $size, |
|
257 | - 'write_time' => (isset($object[ 'write_time' ]) ? $object[ 'write_time' ] : null), |
|
256 | + 'size' => $size, |
|
257 | + 'write_time' => (isset($object[ 'write_time' ]) ? $object[ 'write_time' ] : null), |
|
258 | 258 | ]; |
259 | 259 | if ($object->isExpired()) { |
260 | 260 | @unlink($file_path); |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | $stat->setData($content) |
270 | - ->setSize($total - $removed) |
|
271 | - ->setInfo('Total [bytes]: ' . $total . ', ' |
|
270 | + ->setSize($total - $removed) |
|
271 | + ->setInfo('Total [bytes]: ' . $total . ', ' |
|
272 | 272 | . 'Expired and removed [bytes]: ' . $removed . ', ' |
273 | 273 | . 'Current [bytes], ' . $total - $removed |
274 | - ); |
|
274 | + ); |
|
275 | 275 | |
276 | 276 | return $stat; |
277 | 277 | } |
@@ -127,14 +127,14 @@ |
||
127 | 127 | public function driverConnect() |
128 | 128 | { |
129 | 129 | $server = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : [ |
130 | - 'host' => '127.0.0.1', |
|
131 | - 'port' => '6379', |
|
132 | - 'password' => '', |
|
133 | - 'database' => '', |
|
130 | + 'host' => '127.0.0.1', |
|
131 | + 'port' => '6379', |
|
132 | + 'password' => '', |
|
133 | + 'database' => '', |
|
134 | 134 | ]; |
135 | 135 | |
136 | 136 | $config = [ |
137 | - 'host' => $server[ 'host' ], |
|
137 | + 'host' => $server[ 'host' ], |
|
138 | 138 | ]; |
139 | 139 | |
140 | 140 | $port = isset($server[ 'port' ]) ? $server[ 'port' ] : ''; |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | if ($item instanceof Item) { |
79 | 79 | try { |
80 | 80 | $result = (array) $this->getCollection()->update( |
81 | - ['_id' => $item->getKey()], |
|
82 | - [ |
|
81 | + ['_id' => $item->getKey()], |
|
82 | + [ |
|
83 | 83 | '$set' => [ |
84 | - self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : null), |
|
85 | - self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
84 | + self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : null), |
|
85 | + self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
86 | 86 | ], |
87 | - ], |
|
88 | - ['upsert' => true, 'multiple' => false] |
|
87 | + ], |
|
88 | + ['upsert' => true, 'multiple' => false] |
|
89 | 89 | ); |
90 | 90 | } catch (MongoCursorException $e) { |
91 | 91 | return false; |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | $document = $this->getCollection()->findOne(['_id' => $key], [self::DRIVER_DATA_WRAPPER_INDEX, self::DRIVER_TIME_WRAPPER_INDEX /*'d', 'e'*/]); |
107 | 107 | if ($document) { |
108 | 108 | return [ |
109 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
110 | - self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
109 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
110 | + self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
111 | 111 | ]; |
112 | 112 | } else { |
113 | 113 | return null; |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | * @todo make an url builder |
163 | 163 | */ |
164 | 164 | $this->instance = $this->instance ?: (new MongodbClient('mongodb://' . |
165 | - ($username ?: '') . |
|
166 | - ($password ? ":{$password}" : '') . |
|
167 | - ($username ? '@' : '') . "{$host}" . |
|
168 | - ($port != '27017' ? ":{$port}" : ''), ['timeout' => $timeout * 1000]))->phpFastCache; |
|
165 | + ($username ?: '') . |
|
166 | + ($password ? ":{$password}" : '') . |
|
167 | + ($username ? '@' : '') . "{$host}" . |
|
168 | + ($port != '27017' ? ":{$port}" : ''), ['timeout' => $timeout * 1000]))->phpFastCache; |
|
169 | 169 | $this->instance->Cache->createIndex([self::DRIVER_TIME_WRAPPER_INDEX => 1], ['expireAfterSeconds' => 0]); |
170 | 170 | } |
171 | 171 | } |
@@ -206,23 +206,23 @@ discard block |
||
206 | 206 | public function getStats() |
207 | 207 | { |
208 | 208 | $serverStatus = $this->getCollection()->db->command([ |
209 | - 'serverStatus' => 1, |
|
210 | - 'recordStats' => 0, |
|
211 | - 'repl' => 0, |
|
212 | - 'metrics' => 0, |
|
209 | + 'serverStatus' => 1, |
|
210 | + 'recordStats' => 0, |
|
211 | + 'repl' => 0, |
|
212 | + 'metrics' => 0, |
|
213 | 213 | ]); |
214 | 214 | $collStats = $this->getCollection()->db->command([ |
215 | - 'collStats' => 'Cache', |
|
216 | - 'verbose' => true, |
|
215 | + 'collStats' => 'Cache', |
|
216 | + 'verbose' => true, |
|
217 | 217 | ]); |
218 | 218 | |
219 | 219 | $stats = (new driverStatistic()) |
220 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1)) |
|
221 | - ->setSize((int) $collStats[ 'size' ]) |
|
222 | - ->setRawData([ |
|
220 | + ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1)) |
|
221 | + ->setSize((int) $collStats[ 'size' ]) |
|
222 | + ->setRawData([ |
|
223 | 223 | 'serverStatus' => $serverStatus, |
224 | 224 | 'collStats' => $collStats, |
225 | - ]); |
|
225 | + ]); |
|
226 | 226 | |
227 | 227 | return $stats; |
228 | 228 | } |
@@ -133,7 +133,7 @@ |
||
133 | 133 | $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
134 | 134 | if (count($servers) < 1) { |
135 | 135 | $servers = [ |
136 | - ['127.0.0.1', 11211], |
|
136 | + ['127.0.0.1', 11211], |
|
137 | 137 | ]; |
138 | 138 | } |
139 | 139 |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
136 | 136 | if (count($servers) < 1) { |
137 | 137 | $servers = [ |
138 | - ['127.0.0.1', 11211], |
|
138 | + ['127.0.0.1', 11211], |
|
139 | 139 | ]; |
140 | 140 | } |
141 | 141 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | } else { |
188 | 188 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', |
189 | - gettype($key))); |
|
189 | + gettype($key))); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | return $this->itemInstances[ $key ]; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | return $this; |
206 | 206 | } else { |
207 | 207 | throw new \InvalidArgumentException(sprintf('Invalid Item Class "%s" for this driver.', |
208 | - get_class($item))); |
|
208 | + get_class($item))); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | |
156 | 156 | $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE); |
157 | 157 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
158 | - PDO::ERRMODE_EXCEPTION); |
|
158 | + PDO::ERRMODE_EXCEPTION); |
|
159 | 159 | |
160 | 160 | if ($createTable == true) { |
161 | 161 | $this->initIndexing($PDO); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | // look for keyword |
191 | 191 | $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1"); |
192 | 192 | $stm->execute([ |
193 | - ':keyword' => $keyword, |
|
193 | + ':keyword' => $keyword, |
|
194 | 194 | ]); |
195 | 195 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
196 | 196 | if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | $db = $this->currentDB; |
203 | 203 | $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)"); |
204 | 204 | $stm->execute([ |
205 | - ':keyword' => $keyword, |
|
206 | - ':db' => $db, |
|
205 | + ':keyword' => $keyword, |
|
206 | + ':db' => $db, |
|
207 | 207 | ]); |
208 | 208 | } |
209 | 209 | |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | if ($toWrite == true) { |
275 | 275 | try { |
276 | 276 | $stm = $this->getDb($item->getKey()) |
277 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
277 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
278 | 278 | $stm->execute([ |
279 | - ':keyword' => $item->getKey(), |
|
280 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
281 | - ':exp' => time() + $item->getTtl(), |
|
279 | + ':keyword' => $item->getKey(), |
|
280 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
281 | + ':exp' => time() + $item->getTtl(), |
|
282 | 282 | ]); |
283 | 283 | |
284 | 284 | return true; |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | |
287 | 287 | try { |
288 | 288 | $stm = $this->getDb($item->getKey(), true) |
289 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
289 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
290 | 290 | $stm->execute([ |
291 | - ':keyword' => $item->getKey(), |
|
292 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
293 | - ':exp' => time() + $item->getTtl(), |
|
291 | + ':keyword' => $item->getKey(), |
|
292 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
293 | + ':exp' => time() + $item->getTtl(), |
|
294 | 294 | ]); |
295 | 295 | } catch (PDOException $e) { |
296 | 296 | return false; |
@@ -312,20 +312,20 @@ discard block |
||
312 | 312 | { |
313 | 313 | try { |
314 | 314 | $stm = $this->getDb($key) |
315 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
315 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
316 | 316 | $stm->execute([ |
317 | - ':keyword' => $key, |
|
318 | - ':U' => time(), |
|
317 | + ':keyword' => $key, |
|
318 | + ':U' => time(), |
|
319 | 319 | ]); |
320 | 320 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
321 | 321 | |
322 | 322 | } catch (PDOException $e) { |
323 | 323 | try { |
324 | 324 | $stm = $this->getDb($key, true) |
325 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
325 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
326 | 326 | $stm->execute([ |
327 | - ':keyword' => $key, |
|
328 | - ':U' => time(), |
|
327 | + ':keyword' => $key, |
|
328 | + ':U' => time(), |
|
329 | 329 | ]); |
330 | 330 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
331 | 331 | } catch (PDOException $e) { |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | if ($item instanceof Item) { |
364 | 364 | try { |
365 | 365 | $stm = $this->getDb($item->getKey()) |
366 | - //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
367 | - ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
366 | + //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
367 | + ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
368 | 368 | |
369 | 369 | return $stm->execute([ |
370 | 370 | // ':id' => $row[ 'id' ], |
371 | - ':keyword' => $item->getKey(), |
|
372 | - ':U' => time(), |
|
371 | + ':keyword' => $item->getKey(), |
|
372 | + ':U' => time(), |
|
373 | 373 | ]); |
374 | 374 | } catch (PDOException $e) { |
375 | 375 | return false; |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | { |
406 | 406 | if (!file_exists($this->getPath() . '/' . self::SQLITE_DIR)) { |
407 | 407 | if (!mkdir($this->getPath() . '/' . self::SQLITE_DIR, |
408 | - $this->setChmodAuto()) |
|
408 | + $this->setChmodAuto()) |
|
409 | 409 | ) { |
410 | 410 | $this->fallback = true; |
411 | 411 | } |
@@ -428,10 +428,10 @@ discard block |
||
428 | 428 | * @todo: Check expiration time here |
429 | 429 | */ |
430 | 430 | $stm = $this->getDb($item->getKey()) |
431 | - ->prepare("SELECT COUNT(`id`) as `total` FROM `caching` WHERE (`keyword`=:keyword) AND (`exp` <= :U) "); |
|
431 | + ->prepare("SELECT COUNT(`id`) as `total` FROM `caching` WHERE (`keyword`=:keyword) AND (`exp` <= :U) "); |
|
432 | 432 | $stm->execute([ |
433 | - ':keyword' => $item->getKey(), |
|
434 | - ':U' => time(), |
|
433 | + ':keyword' => $item->getKey(), |
|
434 | + ':U' => time(), |
|
435 | 435 | ]); |
436 | 436 | $data = $stm->fetch(PDO::FETCH_ASSOC); |
437 | 437 | if ($data[ 'total' ] >= 1) { |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | $stat = new driverStatistic(); |
460 | 460 | |
461 | 461 | $res = [ |
462 | - 'info' => '', |
|
463 | - 'size' => '', |
|
464 | - 'data' => '', |
|
462 | + 'info' => '', |
|
463 | + 'size' => '', |
|
464 | + 'data' => '', |
|
465 | 465 | ]; |
466 | 466 | $total = 0; |
467 | 467 | $optimized = 0; |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | try { |
477 | 477 | $PDO = new PDO("sqlite:" . $file_path); |
478 | 478 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
479 | - PDO::ERRMODE_EXCEPTION); |
|
479 | + PDO::ERRMODE_EXCEPTION); |
|
480 | 480 | |
481 | 481 | $stm = $PDO->prepare("DELETE FROM `caching` WHERE `exp` <= :U"); |
482 | 482 | $stm->execute([ |
483 | - ':U' => date('U'), |
|
483 | + ':U' => date('U'), |
|
484 | 484 | ]); |
485 | 485 | |
486 | 486 | $PDO->exec('VACUUM;'); |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | } |
495 | 495 | |
496 | 496 | $stat->setSize($optimized) |
497 | - ->setInfo('Total before removing expired entries [bytes]: ' . $total . ', ' |
|
497 | + ->setInfo('Total before removing expired entries [bytes]: ' . $total . ', ' |
|
498 | 498 | . 'Optimized after removing expired entries [bytes]: ' . $optimized |
499 | - ); |
|
499 | + ); |
|
500 | 500 | |
501 | 501 | return $stat; |
502 | 502 | } |