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