public function Store::lookup

Locates a cached Response for the Request provided.

Parameters

Request $request A Request instance:

Return value

Response|null A Response instance, or null if no cache entry was found

Overrides StoreInterface::lookup

File

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

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) {
  $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]) ? $entry[1]['vary'][0] : '', $request->headers
      ->all(), $entry[0])) {
      $match = $entry;
      break;
    }
  }
  if (null === $match) {
    return null;
  }
  list($req, $headers) = $match;
  if (is_file($body = $this
    ->getPath($headers['x-content-digest'][0]))) {
    return $this
      ->restoreResponse($headers, $body);
  }

  // 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;
}