Example #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;
 }
 /**
  * Invalidate all cached objects matching the provided HTTP headers.
  *
  * Each header is a a POSIX regular expression, for example
  * ['X-Host' => '^(www\.)?(this|that)\.com$']
  *
  * @see BanInterface::ban()
  *
  * @param array $headers HTTP headers that path must match to be banned.
  *
  * @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests
  *
  * @return $this
  */
 public function invalidate(array $headers)
 {
     if (!$this->cache instanceof BanInterface) {
         throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN');
     }
     $this->cache->ban($headers);
     return $this;
 }
Example #3
0
    /**
     * Invalidate cache entries that contain any of the specified tags in their
     * tag header.
     *
     * @see BanInterface::ban()
     *
     * @param array $tags Cache tags
     *
     * @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests
     *
     * @return $this
     */
    public function invalidateTags(array $tags)
    {
        if (!$this->cache instanceof BanInterface) {
            throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN');
        }

        $headers = array($this->getTagsHeader() => '('.implode('|', array_map('preg_quote', $tags)).')(,.+)?$');
        $this->cache->ban($headers);

        return $this;
    }