public function Store::invalidate

Invalidates all cache entries that match the request.

Parameters

Request $request A Request instance:

Throws

\RuntimeException

Overrides StoreInterface::invalidate

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php, line 227

Class

Store
Store implements all the logic for storing cache metadata (Request and Response headers).

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

public function invalidate(Request $request) {
  $modified = false;
  $key = $this
    ->getCacheKey($request);
  $entries = array();
  foreach ($this
    ->getMetadata($key) as $entry) {
    $response = $this
      ->restoreResponse($entry[1]);
    if ($response
      ->isFresh()) {
      $response
        ->expire();
      $modified = true;
      $entries[] = array(
        $entry[0],
        $this
          ->persistResponse($response),
      );
    }
    else {
      $entries[] = $entry;
    }
  }
  if ($modified) {
    if (false === $this
      ->save($key, serialize($entries))) {
      throw new \RuntimeException('Unable to store the metadata.');
    }
  }
}