/** * Invalidate cache entries that contain any of the specified tags in their * tag header. * * @param array $tags Cache tags * * @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests * * @return $this * * @deprecated Use TagHandler::invalidateTags instead. */ public function invalidateTags(array $tags) { if (!$this->tagHandler) { throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN'); } $this->tagHandler->invalidateTags($tags); return $this; }
/** * Clear all cache in Varnish for given tags * * @param array $tags * @param string $domain The domain to flush, e.g. "example.com" * @return void */ public function banByTags(array $tags, $domain = NULL) { if (count($this->settings['ignoredCacheTags']) > 0) { $tags = array_diff($tags, $this->settings['ignoredCacheTags']); } if ($domain !== NULL) { $this->varnishProxyClient->setDefaultBanHeader(ProxyClient\Varnish::HTTP_HEADER_HOST, $domain); } $this->tagHandler->invalidateTags($tags); if ($domain !== NULL) { $this->varnishProxyClient->setDefaultBanHeader(ProxyClient\Varnish::HTTP_HEADER_HOST, ProxyClient\Varnish::REGEX_MATCH_ALL); } $this->systemLogger->log(sprintf('Cleared varnish cache for tags "%s"%s', implode(',', $tags), $domain ? ' for domain "' . $domain . '"' : '')); $this->execute(); }
/** * Clear all cache in Varnish for given tags * * @param array $tags * @param string $domain The domain to flush, e.g. "example.com" * @return void */ public function banByTags(array $tags, $domain = NULL) { if (count($this->settings['ignoredCacheTags']) > 0) { $tags = array_diff($tags, $this->settings['ignoredCacheTags']); } /** * Sanitize tags * @see \TYPO3\TypoScript\Core\Cache\ContentCache */ foreach ($tags as $key => $tag) { $tags[$key] = strtr($tag, '.:', '_-'); } // Set specific domain before invalidating tags if ($domain !== NULL) { $this->varnishProxyClient->setDefaultBanHeader(ProxyClient\Varnish::HTTP_HEADER_HOST, $domain); } $this->tagHandler->invalidateTags($tags); // Unset specific domain after invalidating tags if ($domain !== NULL) { $this->varnishProxyClient->setDefaultBanHeader(ProxyClient\Varnish::HTTP_HEADER_HOST, ProxyClient\Varnish::REGEX_MATCH_ALL); } $this->logger->log(sprintf('Cleared Varnish cache for tags "%s"%s', implode(',', $tags), $domain ? ' for domain "' . $domain . '"' : '')); $this->execute(); }
/** * Add a single tag or an array of tags to the response. * * The tag string is *not* further processed, you can't use a comma * separated string to pass several tags but need to build a twig array. * * Calling this twig function adds nothing to the output. * * @param string|array $tag */ public function addTag($tag) { $this->tagHandler->addTags((array) $tag); }
/** * Invalidate cache by tags * * @param array $tags */ public function invalidateTags(array $tags) { if (!is_null($this->tagHandler)) { $this->tagHandler->invalidateTags($tags); } }