static function purge($urlArr) { $caller = self::getPurgeCaller(); wfDebug("Purging backtrace: " . wfGetAllCallers(false) . "\n"); // Filter urls into buckets based on service backend $buckets = array_reduce($urlArr, function ($carry, $item) use($caller) { global $wgPurgeVignetteUsingSurrogateKeys; wfDebug("Purging URL {$item} from {$caller} via Celery\n"); if (isset($wgPurgeVignetteUsingSurrogateKeys) && VignetteRequest::isVignetteUrl($item)) { $carry['vignette'][] = $item; } elseif (strstr($item, 'MercuryApi') !== false) { $carry['mercury'][] = $item; $carry['mediawiki'][] = $item; // TODO: we can remove this when mercury is only using internal cache } else { $carry['mediawiki'][] = $item; } return $carry; }, array('mediawiki' => [], 'vignette' => [], 'mercury' => [])); if (empty(CeleryPurge::$buckets)) { CeleryPurge::$buckets = $buckets; } else { CeleryPurge::$buckets = array_merge_recursive(CeleryPurge::$buckets, $buckets); } }
/** * Purges a list of Squids defined in $wgSquidServers. * $urlArr should contain the full URLs to purge as values * (example: $urlArr[] = 'http://my.host/something') * XXX report broken Squids per mail or log * * @param $urlArr array * @return void */ static function purge($urlArr) { global $wgSquidServers, $wgHTCPMulticastAddress, $wgHTCPPort; /*if ( (@$wgSquidServers[0]) == 'echo' ) { echo implode("<br />\n", $urlArr) . "<br />\n"; return; }*/ if (!$urlArr) { return; } // wikia change start global $wgPurgeSquidViaScribe; if ($wgPurgeSquidViaScribe == true) { ScribePurge::purge($urlArr); return; } global $wgPurgeSquidViaCelery; if ($wgPurgeSquidViaCelery == true) { CeleryPurge::purge($urlArr); return; } // wikia change end if ($wgHTCPMulticastAddress && $wgHTCPPort) { SquidUpdate::HTCPPurge($urlArr); } wfProfileIn(__METHOD__); $maxSocketsPerSquid = 8; // socket cap per Squid $urlsPerSocket = 400; // 400 seems to be a good tradeoff, opening a socket takes a while $socketsPerSquid = ceil(count($urlArr) / $urlsPerSocket); if ($socketsPerSquid > $maxSocketsPerSquid) { $socketsPerSquid = $maxSocketsPerSquid; } $pool = new SquidPurgeClientPool(); $chunks = array_chunk($urlArr, ceil(count($urlArr) / $socketsPerSquid)); foreach ($wgSquidServers as $server) { foreach ($chunks as $chunk) { $client = new SquidPurgeClient($server); foreach ($chunk as $url) { $client->queuePurge($url); } $pool->addClient($client); } } $pool->run(); wfProfileOut(__METHOD__); }