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

Breadcrumb

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

function Store::lookup

Locates a cached Response for the Request provided.

Overrides StoreInterface::lookup

File

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

Class

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

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

public function lookup(Request $request) : ?Response {
    $key = $this->getCacheKey($request);
    if (!($entries = $this->getMetadata($key))) {
        return null;
    }
    // find a cached entry that matches the request.
    $match = null;
    foreach ($entries as $entry) {
        if ($this->requestsMatch(isset($entry[1]['vary'][0]) ? implode(', ', $entry[1]['vary']) : '', $request->headers
            ->all(), $entry[0])) {
            $match = $entry;
            break;
        }
    }
    if (null === $match) {
        return null;
    }
    $headers = $match[1];
    if (file_exists($path = $this->getPath($headers['x-content-digest'][0]))) {
        return $this->restoreResponse($headers, $path);
    }
    // TODO the metaStore referenced an entity that doesn't exist in
    // the entityStore. We definitely want to return nil but we should
    // also purge the entry from the meta-store when this is detected.
    return null;
}

API Navigation

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