|
1 | 1 | <?php
|
| 2 | + |
2 | 3 | /**
|
3 | 4 | * Cache-Verwaltung.
|
4 | 5 | */
|
|
16 | 17 | use function is_array;
|
17 | 18 | use function is_bool;
|
18 | 19 |
|
| 20 | +use const GLOB_NOSORT; |
| 21 | + |
19 | 22 | class Cache
|
20 | 23 | {
|
21 | 24 | /**
|
@@ -46,7 +49,7 @@ public function sendCacheFile(string $filePath, string $contentType, int $ttl):
|
46 | 49 | $time2elapse = $timestamp + ($ttl * 60);
|
47 | 50 |
|
48 | 51 | rex_response::cleanOutputBuffers();
|
49 |
| - rex_response::setHeader('Expires', gmdate('D, d M Y H:i:s', $time2elapse) .' GMT'); |
| 52 | + rex_response::setHeader('Expires', gmdate('D, d M Y H:i:s', $time2elapse) . ' GMT'); |
50 | 53 | rex_response::sendCacheControl('public, max-age=' . $ttl * 60);
|
51 | 54 | rex_response::sendFile($filePath, $contentType);
|
52 | 55 | exit;
|
@@ -93,7 +96,7 @@ public static function clearLayerCache(int $layer): int
|
93 | 96 | if (0 < $layer) {
|
94 | 97 | $targetDir = rex_path::addonCache(ADDON, (string) $layer);
|
95 | 98 | if (is_dir($targetDir)) {
|
96 |
| - $files = glob($targetDir.'/*', GLOB_NOSORT); |
| 99 | + $files = glob($targetDir . '/*', GLOB_NOSORT); |
97 | 100 | if (is_array($files)) {
|
98 | 101 | $deletedFiles = count($files);
|
99 | 102 | $deletedFiles = rex_dir::delete($targetDir, true) ? $deletedFiles : 0;
|
@@ -124,7 +127,7 @@ public static function clearCache(): int
|
124 | 127 | $layerCaches = preg_grep('/\d+/', $layerCaches);
|
125 | 128 | if (is_array($layerCaches)) {
|
126 | 129 | foreach ($layerCaches as $layer) {
|
127 |
| - $liste = scandir($targetDir.$layer); |
| 130 | + $liste = scandir($targetDir . $layer); |
128 | 131 | if (is_array($liste)) {
|
129 | 132 | $deletedFiles += (count($liste) - 2); // ohne . und ..
|
130 | 133 | }
|
@@ -198,7 +201,7 @@ public static function cleanupLayerCache(int $layer = 0, int $threshold = CFM_DE
|
198 | 201 | $threshold = max($threshold, CFM_MIN);
|
199 | 202 | $ttl = max($ttl, TTL_MIN);
|
200 | 203 |
|
201 |
| - $targetDir = rex_path::addonCache(ADDON, $layer.'/'); |
| 204 | + $targetDir = rex_path::addonCache(ADDON, $layer . '/'); |
202 | 205 | $targetTime = time() - ($ttl * 60);
|
203 | 206 | $timeString = date('Y-m-d G-H-s', $targetTime);
|
204 | 207 |
|
|
0 commit comments