cacheProvider; } public function setActiveCacheProvider(?string $key): void { $this->cacheProvider = $this->getRegisteredCacheProviders()[$key] ?? null; $this->cacheProvider?->init(); } public function generateCacheKey(...$keyParts): string { return implode('|', $keyParts); } public function add(string $key, mixed $value): void { $this->cacheProvider?->add($key, $value); $this->cache[$key] = $value; } public function get(string $key): mixed { if (isset($this->cache[$key]) === false) { $this->cache[$key] = $this->cacheProvider?->get($key); } return $this->cache[$key]; } public function invalidate(string $key): void { $this->cacheProvider?->invalidate($key); unset($this->cache[$key]); } public function addToRuntimeCache(string $key, mixed $value): void { $this->runtimeCache[$key] = $value; } public function getFromRuntimeCache(string $key): mixed { return $this->runtimeCache[$key] ?? null; } public function flushCache(): void { $this->cache = []; $this->runtimeCache = []; } /** * @return CacheProviderInterface[] */ public function getRegisteredCacheProviders(): array { $fileSystemCacheProvider = $this->cacheProviderFactory->createFileSystemCacheProvider(); $providers = [$fileSystemCacheProvider->getId() => $fileSystemCacheProvider]; if ($this->wordpress->isUsingExtObjectCache() === true) { $redisCacheProvider = $this->cacheProviderFactory->createRedisCacheProvider(); $providers[$redisCacheProvider->getId()] = $redisCacheProvider; } return $this->wordpress->applyFilters('uam_registered_cache_handlers', $providers); } }