@@ -36,7 +36,7 @@ |
||
| 36 | 36 | * true = Activé, prend en compte tous les paramètres de requête. |
| 37 | 37 | * Veuillez noter que cela peut entraîner de nombreux fichiers de cache générés encore et encore pour la même page. |
| 38 | 38 | * array('q') = Activé, mais ne prend en compte que la liste spécifiée de paramètres de requête. |
| 39 | - */ |
|
| 39 | + */ |
|
| 40 | 40 | public function __construct(private CacheInterface $cache, private array|bool $cacheQueryString = false) |
| 41 | 41 | { |
| 42 | 42 | } |
@@ -182,9 +182,9 @@ |
||
| 182 | 182 | $ttl = null; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if (null !== $value = $this->get($key)) { |
|
| 186 | - return $value; |
|
| 187 | - } |
|
| 185 | + if (null !== $value = $this->get($key)) { |
|
| 186 | + return $value; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | $this->set($key, $value = $callable(), $ttl); |
| 190 | 190 | |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Tente de créer le gestionnaire de cache souhaité |
| 103 | - * |
|
| 104 | - * @return BaseHandler |
|
| 103 | + * |
|
| 104 | + * @return BaseHandler |
|
| 105 | 105 | */ |
| 106 | 106 | protected function factory(): CacheInterface |
| 107 | 107 | { |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * ``` |
| 253 | 253 | * $cache->read('my_data'); |
| 254 | - * ``` |
|
| 254 | + * ``` |
|
| 255 | 255 | */ |
| 256 | 256 | public function read(string $key, mixed $default = null): mixed |
| 257 | 257 | { |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | * ``` |
| 292 | 292 | * $cache->readMany(['my_data_1', 'my_data_2']); |
| 293 | - * ``` |
|
| 293 | + * ``` |
|
| 294 | 294 | */ |
| 295 | 295 | public function readMany(iterable $keys, mixed $default = null): iterable |
| 296 | 296 | { |
@@ -529,14 +529,14 @@ discard block |
||
| 529 | 529 | return $this->factory()->has($key); |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - /** |
|
| 533 | - * Récupérez un élément du cache et supprimez-le. |
|
| 534 | - * |
|
| 535 | - * @template TCacheValue |
|
| 536 | - * |
|
| 537 | - * @param TCacheValue|(\Closure(): TCacheValue) $default |
|
| 538 | - * @return (TCacheValue is null ? mixed : TCacheValue) |
|
| 539 | - */ |
|
| 532 | + /** |
|
| 533 | + * Récupérez un élément du cache et supprimez-le. |
|
| 534 | + * |
|
| 535 | + * @template TCacheValue |
|
| 536 | + * |
|
| 537 | + * @param TCacheValue|(\Closure(): TCacheValue) $default |
|
| 538 | + * @return (TCacheValue is null ? mixed : TCacheValue) |
|
| 539 | + */ |
|
| 540 | 540 | public function pull(string $key, $default = null) |
| 541 | 541 | { |
| 542 | 542 | return Helpers::tap($this->read($key, $default), function () use ($key) { |
@@ -544,14 +544,14 @@ discard block |
||
| 544 | 544 | }); |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - /** |
|
| 548 | - * Récupérez un élément du cache et supprimez-le. |
|
| 549 | - * |
|
| 550 | - * @template TCacheValue |
|
| 551 | - * |
|
| 552 | - * @param TCacheValue|(\Closure(): TCacheValue) $default |
|
| 553 | - * @return (TCacheValue is null ? mixed : TCacheValue) |
|
| 554 | - */ |
|
| 547 | + /** |
|
| 548 | + * Récupérez un élément du cache et supprimez-le. |
|
| 549 | + * |
|
| 550 | + * @template TCacheValue |
|
| 551 | + * |
|
| 552 | + * @param TCacheValue|(\Closure(): TCacheValue) $default |
|
| 553 | + * @return (TCacheValue is null ? mixed : TCacheValue) |
|
| 554 | + */ |
|
| 555 | 555 | public function pullMany(iterable $keys, $default = null) |
| 556 | 556 | { |
| 557 | 557 | return Helpers::tap($this->readMany($keys, $default), function () use ($keys) { |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * Dossier de stockage des fichiers mis en cache. |
| 20 | 20 | */ |
| 21 | - private string $path; |
|
| 21 | + private string $path; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Constructeur |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * {@inheritDoc} |
| 57 | - * |
|
| 58 | - * @param array|bool|float|int|object|string|null $value |
|
| 57 | + * |
|
| 58 | + * @param array|bool|float|int|object|string|null $value |
|
| 59 | 59 | */ |
| 60 | 60 | public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool |
| 61 | 61 | { |
@@ -78,13 +78,13 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * {@inheritDoc} |
| 81 | - * |
|
| 82 | - * @return array|bool|float|int|object|string|null |
|
| 81 | + * |
|
| 82 | + * @return array|bool|float|int|object|string|null |
|
| 83 | 83 | */ |
| 84 | 84 | public function get(string $key, mixed $default = null): mixed |
| 85 | 85 | { |
| 86 | - return @include $this->path . "/{$key}"; |
|
| 87 | - } |
|
| 86 | + return @include $this->path . "/{$key}"; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * {@inheritDoc} |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function delete(string $key): bool |
| 117 | 117 | { |
| 118 | - return @unlink($this->path . "/{$key}"); |
|
| 118 | + return @unlink($this->path . "/{$key}"); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -131,21 +131,21 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function clear(): bool |
| 133 | 133 | { |
| 134 | - if (! is_dir($this->path)) { |
|
| 135 | - return false; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $files = glob($this->path . '/*'); |
|
| 139 | - foreach ($files as $file) { |
|
| 140 | - if (is_file($file)) { |
|
| 141 | - unlink($file); |
|
| 142 | - } elseif (is_dir($file)) { |
|
| 143 | - $this->clear($file); |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - return rmdir($this->path); |
|
| 148 | - } |
|
| 134 | + if (! is_dir($this->path)) { |
|
| 135 | + return false; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $files = glob($this->path . '/*'); |
|
| 139 | + foreach ($files as $file) { |
|
| 140 | + if (is_file($file)) { |
|
| 141 | + unlink($file); |
|
| 142 | + } elseif (is_dir($file)) { |
|
| 143 | + $this->clear($file); |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + return rmdir($this->path); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * {@inheritDoc} |