| @@ -28,11 +28,13 @@ | ||
| 28 | 28 | $this->cacheProvider = $this->getRegisteredCacheProviders()[$key] ?? null; |
| 29 | 29 | $this->cacheProvider?->init(); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function generateCacheKey(...$keyParts): string | |
| 32 | + public function generateCacheKey(): string | |
| 33 | 33 | { |
| 34 | - return implode('|', $keyParts); | |
| 34 | + $arguments = func_get_args(); | |
| 35 | + | |
| 36 | + return implode('|', $arguments); | |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | 39 | public function add(string $key, mixed $value): void |
| 38 | 40 | { |
| @@ -42,9 +44,9 @@ | ||
| 42 | 44 | |
| 43 | 45 | public function get(string $key): mixed |
| 44 | 46 | { |
| 45 | 47 | if (isset($this->cache[$key]) === false) { |
| 46 | - $this->cache[$key] = $this->cacheProvider?->get($key); | |
| 48 | + $this->cache[$key] = ($this->cacheProvider !== null) ? $this->cacheProvider->get($key) : null; | |
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | return $this->cache[$key]; |
| 50 | 52 | } |
| @@ -61,11 +63,16 @@ | ||
| 61 | 63 | } |
| 62 | 64 | |
| 63 | 65 | public function getFromRuntimeCache(string $key): mixed |
| 64 | 66 | { |
| 65 | - return $this->runtimeCache[$key] ?? null; | |
| 67 | + if (isset($this->runtimeCache[$key]) === true) { | |
| 68 | + return $this->runtimeCache[$key]; | |
| 69 | + } | |
| 70 | + | |
| 71 | + return null; | |
| 66 | 72 | } |
| 67 | 73 | |
| 74 | + | |
| 68 | 75 | public function flushCache(): void |
| 69 | 76 | { |
| 70 | 77 | $this->cache = []; |
| 71 | 78 | $this->runtimeCache = []; |
| @@ -76,14 +83,11 @@ | ||
| 76 | 83 | */ |
| 77 | 84 | public function getRegisteredCacheProviders(): array |
| 78 | 85 | { |
| 79 | 86 | $fileSystemCacheProvider = $this->cacheProviderFactory->createFileSystemCacheProvider(); |
| 80 | - $providers = [$fileSystemCacheProvider->getId() => $fileSystemCacheProvider]; | |
| 81 | 87 | |
| 82 | - if ($this->wordpress->isUsingExtObjectCache() === true) { | |
| 83 | - $redisCacheProvider = $this->cacheProviderFactory->createRedisCacheProvider(); | |
| 84 | - $providers[$redisCacheProvider->getId()] = $redisCacheProvider; | |
| 85 | - } | |
| 86 | - | |
| 87 | - return $this->wordpress->applyFilters('uam_registered_cache_handlers', $providers); | |
| 88 | + return $this->wordpress->applyFilters( | |
| 89 | + 'uam_registered_cache_handlers', | |
| 90 | + [$fileSystemCacheProvider->getId() => $fileSystemCacheProvider] | |
| 91 | + ); | |
| 88 | 92 | } |
| 89 | 93 | } |