You are here

public function Store::lookup in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/HttpCache/Store.php \Symfony\Component\HttpKernel\HttpCache\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

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

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

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