Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Store.php

function Store::invalidate

Invalidates all cache entries that match the request.

Throws

\RuntimeException

Overrides StoreInterface::invalidate

File

vendor/symfony/http-kernel/HttpCache/Store.php, line 249

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) : void {
    $modified = false;
    $key = $this->getCacheKey($request);
    $entries = [];
    foreach ($this->getMetadata($key) as $entry) {
        $response = $this->restoreResponse($entry[1]);
        if ($response->isFresh()) {
            $response->expire();
            $modified = true;
            $entries[] = [
                $entry[0],
                $this->persistResponse($response),
            ];
        }
        else {
            $entries[] = $entry;
        }
    }
    if ($modified && !$this->save($key, serialize($entries))) {
        throw new \RuntimeException('Unable to store the metadata.');
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal