Locates a cached Response for the Request provided.
Request $request A Request instance:
Response|null A Response instance, or null if no cache entry was found
Overrides StoreInterface::lookup
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;
}