Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function flush()
 {
     if (!$this->structuresToInvalidate) {
         return false;
     }
     foreach ($this->structuresToInvalidate as $structure) {
         $banKey = $this->getBanKey($structure->getUuid());
         $this->proxyClient->ban([self::TAGS_HEADER => sprintf('(%s)(,.+)?$', preg_quote($banKey))]);
     }
     $this->proxyClient->flush();
     return true;
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function flush()
 {
     if (!$this->proxyClient instanceof PurgeInterface) {
         return false;
     }
     if (!$this->pathsToInvalidate) {
         return true;
     }
     foreach ($this->pathsToInvalidate as $entry) {
         $this->proxyClient->purge($entry['path'], $entry['headers']);
     }
     $this->proxyClient->flush();
     return true;
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function clear()
 {
     if ($this->proxyClient instanceof BanInterface) {
         $request = $this->requestStack->getCurrentRequest();
         if (!$request) {
             return;
         }
         $this->proxyClient->banPath(BanInterface::REGEX_MATCH_ALL, BanInterface::CONTENT_TYPE_ALL, [$request->getHost()]);
         return $this->proxyClient->flush();
     }
     $path = sprintf('%s/cache/website/%s/http_cache', $this->varDir ?: $this->kernelRootDir, $this->kernelEnvironment);
     if ($this->filesystem->exists($path)) {
         $this->filesystem->remove($path);
     }
 }
Beispiel #4
0
 /**
  * {@inheritDoc}
  */
 public function flush()
 {
     if (!$this->structuresToInvalidate) {
         return;
     }
     foreach ($this->structuresToInvalidate as $structure) {
         if (false === $structure->hasTag('sulu.rlp') || null === ($rlp = $structure->getPropertyValueByTagName('sulu.rlp'))) {
             return;
         }
         $urls = $this->webspaceManager->findUrlsByResourceLocator($rlp, $this->environment, $structure->getLanguageCode(), $structure->getWebspaceKey());
         foreach ($urls as $url) {
             $this->proxyClient->purge($url);
         }
     }
     $this->proxyClient->flush();
 }
 /**
  * Send all pending invalidation requests.
  *
  * @return int The number of cache invalidations performed per caching server.
  *
  * @throws ExceptionCollection If any errors occurred during flush.
  */
 public function flush()
 {
     try {
         return $this->cache->flush();
     } catch (ExceptionCollection $exceptions) {
         foreach ($exceptions as $exception) {
             $event = new Event();
             $event->setException($exception);
             if ($exception instanceof ProxyResponseException) {
                 $this->getEventDispatcher()->dispatch(Events::PROXY_RESPONSE_ERROR, $event);
             } elseif ($exception instanceof ProxyUnreachableException) {
                 $this->getEventDispatcher()->dispatch(Events::PROXY_UNREACHABLE_ERROR, $event);
             }
         }
         throw $exceptions;
     }
 }