public function getCacheKey(Localization $localization, Block $block, ResponseContext $context = null) { return sprintf('supra_block_cache_%s_%s_%s', $localization->getId(), $block->getId(), $this->getContextKey($context)); }
/** * @param Block $block * @param Localization $localization * @param ResponseContext $context * @return void */ private function loadResponseCache(Block $block, Localization $localization, ResponseContext $context = null) { $blockId = $block->getId(); if (!array_key_exists($blockId, $this->blockCacheRequests)) { return; } $blockCache = $this->blockCacheRequests[$blockId]; /* @var $blockCache CacheMapper */ $cacheKey = $blockCache->getCacheKey($localization, $block, $context); if (empty($cacheKey)) { // Cache disabled, forget the request unset($this->blockCacheRequests[$blockId]); return; } $cache = $this->container->getCache(); $content = $cache->fetch('block_cache', $cacheKey); if ($content === false) { return; } $responseCache = unserialize($content); if (!$responseCache instanceof ResponsePart) { return; } /* @var $responseCache ResponsePart */ $this->blockContentCache[$blockId] = $responseCache; // Cache found, don't need to cache unset($this->blockCacheRequests[$blockId]); // Don't load properties $this->pageRequest->skipBlockPropertyLoading($blockId); // Rewrite controller instance $this->blockControllers[$blockId] = new CachedBlockController($this->blockContentCache[$blockId], $block); $cachedContext = $responseCache->getContext(); if ($cachedContext !== null) { $cachedContext->flushToContext($this->pageResponse->getContext()); } }