<?php
/**
- * Squid cache purging.
+ * CDN cache purging.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
use Wikimedia\Assert\Assert;
/**
- * Handles purging appropriate Squid URLs given a title (or titles)
+ * Handles purging appropriate CDN URLs given a title (or titles)
* @ingroup Cache
*/
class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
$this->urls = $urlArr;
}
+ public function merge( MergeableUpdate $update ) {
+ /** @var CdnCacheUpdate $update */
+ Assert::parameterType( __CLASS__, $update, '$update' );
+
+ $this->urls = array_merge( $this->urls, $update->urls );
+ }
+
/**
* Create an update object from an array of Title objects, or a TitleArray object
*
public static function newFromTitles( $titles, $urlArr = array() ) {
/** @var Title $title */
foreach ( $titles as $title ) {
- $urlArr = array_merge( $urlArr, $title->getSquidURLs() );
+ $urlArr = array_merge( $urlArr, $title->getCdnUrls() );
}
return new CdnCacheUpdate( $urlArr );
* @deprecated 1.27
*/
public static function newSimplePurge( Title $title ) {
- return new CdnCacheUpdate( $title->getSquidURLs() );
+ return new CdnCacheUpdate( $title->getCdnUrls() );
}
/**
* Purges the list of URLs passed to the constructor.
*/
public function doUpdate() {
- self::purge( $this->urls );
- }
+ global $wgCdnReboundPurgeDelay;
- public function merge( MergeableUpdate $update ) {
- /** @var CdnCacheUpdate $update */
- Assert::parameterType( __CLASS__, $update, '$update' );
+ self::purge( $this->urls );
- $this->urls = array_merge( $this->urls, $update->urls );
+ if ( $wgCdnReboundPurgeDelay > 0 ) {
+ JobQueueGroup::singleton()->lazyPush( new CdnPurgeJob(
+ Title::makeTitle( NS_SPECIAL, 'Badtitle/' . __CLASS__ ),
+ array(
+ 'urls' => $this->urls,
+ 'jobReleaseTimestamp' => time() + $wgCdnReboundPurgeDelay
+ )
+ ) );
+ }
}
/**
- * Purges a list of Squids defined in $wgSquidServers.
+ * Purges a list of CDN nodes 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 string[] $urlArr List of full URLs to purge
*/