*/
class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
/** @var string[] Collection of URLs to purge */
- protected $urls = array();
+ protected $urls = [];
/**
* @param string[] $urlArr Collection of URLs to purge
* @param string[] $urlArr
* @return CdnCacheUpdate
*/
- public static function newFromTitles( $titles, $urlArr = array() ) {
+ public static function newFromTitles( $titles, $urlArr = [] ) {
/** @var Title $title */
foreach ( $titles as $title ) {
$urlArr = array_merge( $urlArr, $title->getCdnUrls() );
if ( $wgCdnReboundPurgeDelay > 0 ) {
JobQueueGroup::singleton()->lazyPush( new CdnPurgeJob(
Title::makeTitle( NS_SPECIAL, 'Badtitle/' . __CLASS__ ),
- array(
+ [
'urls' => $this->urls,
'jobReleaseTimestamp' => time() + $wgCdnReboundPurgeDelay
- )
+ ]
) );
}
}
wfDebugLog( 'squid', __METHOD__ . ': ' . implode( ' ', $urlArr ) );
+ // Reliably broadcast the purge to all edge nodes
+ $relayer = EventRelayerGroup::singleton()->getRelayer( 'cdn-url-purges' );
+ $relayer->notify(
+ 'cdn-url-purges',
+ [
+ 'urls' => array_values( $urlArr ), // JSON array
+ 'timestamp' => microtime( true )
+ ]
+ );
+
+ // Send lossy UDP broadcasting if enabled
if ( $wgHTCPRouting ) {
self::HTCPPurge( $urlArr );
}
+ // Do direct server purges if enabled (this does not scale very well)
if ( $wgSquidServers ) {
// Maximum number of parallel connections per squid
$maxSocketsPerSquid = 8;
if ( isset( $conf['host'] ) && isset( $conf['port'] ) ) {
// Normalize single entries
- $conf = array( $conf );
+ $conf = [ $conf ];
}
foreach ( $conf as $subconf ) {
if ( !isset( $subconf['host'] ) || !isset( $subconf['port'] ) ) {