protected function FastlyPurger::invalidateItems in Fastly 8.3
Invalidate Fastly cache.
Parameters
mixed $type: Type to purge like tags/url. If null, will purge everything.
string[] $invalidates: A list of items to invalidate.
Return value
int Returns invalidate items.
3 calls to FastlyPurger::invalidateItems()
- FastlyPurger::invalidateAll in modules/
fastlypurger/ src/ Plugin/ Purge/ Purger/ FastlyPurger.php - Invalidate everything.
- FastlyPurger::invalidateTags in modules/
fastlypurger/ src/ Plugin/ Purge/ Purger/ FastlyPurger.php - Invalidate a set of tags.
- FastlyPurger::invalidateUrls in modules/
fastlypurger/ src/ Plugin/ Purge/ Purger/ FastlyPurger.php - Invalidate a set of urls.
File
- modules/
fastlypurger/ src/ Plugin/ Purge/ Purger/ FastlyPurger.php, line 204
Class
- FastlyPurger
- Fastly purger.
Namespace
Drupal\fastlypurger\Plugin\Purge\PurgerCode
protected function invalidateItems($type = NULL, array $invalidates = []) {
try {
if ($type === 'tags') {
$purged = $this->api
->purgeKeys($invalidates);
}
elseif ($type === 'urls') {
// $invalidates should be an array with one URL.
foreach ($invalidates as $invalidate) {
$purged = $this->api
->purgeUrl($invalidate);
}
}
else {
$purged = $this->api
->purgeAll();
}
if ($purged) {
return InvalidationInterface::SUCCEEDED;
}
return InvalidationInterface::FAILED;
} catch (\Exception $e) {
return InvalidationInterface::FAILED;
} finally {
// @TODO: Check/increment API limits - https://docs.fastly.com/api/#rate-limiting.
}
}