diff --git a/src/Cachers/CloudflareCacher.php b/src/Cachers/CloudflareCacher.php index 3c7b517..a511deb 100644 --- a/src/Cachers/CloudflareCacher.php +++ b/src/Cachers/CloudflareCacher.php @@ -93,13 +93,7 @@ public function invalidateUrl($url) { $this->strategy()->invalidateUrl($url); - Cloudflare::zones()->each(function ($zone) use ($url) { - if (Cloudflare::shouldQueue()) { - PurgeZoneUrls::dispatch($zone, [$url]); - } else { - PurgeZoneUrls::dispatchSync($zone, [$url]); - } - }); + $this->invalidateZoneUrls([$url]); } /** @@ -112,9 +106,7 @@ public function invalidateUrls($urls) { $this->strategy()->invalidateUrls($urls); - collect($urls)->each(function ($url) { - $this->invalidateUrl($url); - }); + $this->invalidateZoneUrls((array) $urls); } /** @@ -127,4 +119,15 @@ public function getUrls($domain = null) { return $this->strategy()->getUrls($domain); } + + private function invalidateZoneUrls(array $urls) + { + Cloudflare::zones()->each(function ($zone) use ($urls) { + if (Cloudflare::shouldQueue()) { + PurgeZoneUrls::dispatch($zone, $urls); + } else { + PurgeZoneUrls::dispatchSync($zone, $urls); + } + }); + } }