public function ZeroConfigPurger::invalidateWildcardUrls in Varnish purger 8.2
Invalidate URLs that contain the wildcard character "*".
Parameters
\Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface[] $invalidations:
See also
\Drupal\purge\Plugin\Purge\Purger\PurgerInterface::routeTypeToMethod()
\Drupal\purge\Plugin\Purge\Purger\PurgerInterface::invalidate()
File
- src/
Plugin/ Purge/ Purger/ ZeroConfigPurger.php, line 415
Class
- ZeroConfigPurger
- A purger with minimal configuration required.
Namespace
Drupal\varnish_purger\Plugin\Purge\PurgerCode
public function invalidateWildcardUrls(array $invalidations) {
$this
->debug(__METHOD__);
// Change all invalidation objects into the PROCESS state before kickoff.
foreach ($invalidations as $inv) {
$inv
->setState(InvalidationInterface::PROCESSING);
}
// Generate request objects for each balancer/invalidation combination.
$ipv4_addresses = $this
->getReverseProxies();
$requests = function () use ($invalidations, $ipv4_addresses) {
foreach ($invalidations as $inv) {
foreach ($ipv4_addresses as $ipv4) {
(yield $inv
->getId() => function ($poolopt) use ($inv, $ipv4) {
$uri = (new Uri($inv
->getExpression()))
->withScheme('http');
$host = $uri
->getHost();
$uri = $uri
->withHost($ipv4);
$opt = [
'headers' => [
'Accept-Encoding' => 'gzip',
'Host' => $host,
],
];
if (is_array($poolopt) && count($poolopt)) {
$opt = array_merge($poolopt, $opt);
}
return $this->client
->requestAsync('BAN', $uri, $opt);
});
}
}
};
// Execute the requests generator and retrieve the results.
$results = $this
->getResultsConcurrently('invalidateWildcardUrls', $requests);
// Triage the results and set all invalidation states correspondingly.
$this
->triageResults($invalidations, $results);
$this
->debug(__METHOD__);
}