function Store::invalidate
Invalidates all cache entries that match the request.
Throws
\RuntimeException
Overrides StoreInterface::invalidate
File
-
vendor/
symfony/ http-kernel/ HttpCache/ Store.php, line 249
Class
- Store
- Store implements all the logic for storing cache metadata (Request and Response headers).
Namespace
Symfony\Component\HttpKernel\HttpCacheCode
public function invalidate(Request $request) : void {
$modified = false;
$key = $this->getCacheKey($request);
$entries = [];
foreach ($this->getMetadata($key) as $entry) {
$response = $this->restoreResponse($entry[1]);
if ($response->isFresh()) {
$response->expire();
$modified = true;
$entries[] = [
$entry[0],
$this->persistResponse($response),
];
}
else {
$entries[] = $entry;
}
}
if ($modified && !$this->save($key, serialize($entries))) {
throw new \RuntimeException('Unable to store the metadata.');
}
}