MediaWiki REL1_37
CdnCacheUpdate Class Reference

Handles purging the appropriate CDN objects given a list of URLs or Title instances. More...

Inheritance diagram for CdnCacheUpdate:
Collaboration diagram for CdnCacheUpdate:

Public Member Functions

 __construct (array $targets, array $options=[])
 
 doUpdate ()
 Perform the actual work.
 
 getUrls ()
 
 merge (MergeableUpdate $update)
 Merge this enqueued update with a new MergeableUpdate of the same qualified class name.
 

Static Public Member Functions

static newFromTitles ( $pages, $urls=[])
 Create an update object from an array of Title objects, or a TitleArray object.
 
static purge (array $urls)
 Purges a list of CDN nodes defined in $wgCdnServers.
 

Private Member Functions

 resolveReboundDelayByUrl ()
 

Static Private Member Functions

static expand ( $url)
 Expand local URLs to fully-qualified URLs using the internal protocol and host defined in $wgInternalServer.
 
static getRuleForURL ( $url, $rules)
 Find the HTCP routing rule to use for a given URL.
 
static HTCPPurge (array $urls)
 Send Hyper Text Caching Protocol (HTCP) CLR requests.
 
static naivePurge (array $urls)
 Send HTTP PURGE requests for each of the URLs to all of the cache servers.
 

Private Attributes

array[] $pageTuples = []
 List of (PageReference, rebound purge delay) tuples.
 
array[] $urlTuples = []
 List of (URL, rebound purge delay) tuples.
 

Detailed Description

Handles purging the appropriate CDN objects given a list of URLs or Title instances.

Definition at line 29 of file CdnCacheUpdate.php.

Constructor & Destructor Documentation

◆ __construct()

CdnCacheUpdate::__construct ( array  $targets,
array  $options = [] 
)
Parameters
string[] | PageReference[]$targetsCollection of URLs/titles to be purged from CDN
array$optionsOptions map. Supports:
  • reboundDelay: how many seconds after the first purge to send a rebound purge. No rebound purge will be sent if this is not positive. [Default: 0]

Definition at line 44 of file CdnCacheUpdate.php.

Member Function Documentation

◆ doUpdate()

CdnCacheUpdate::doUpdate ( )

Perform the actual work.

Implements DeferrableUpdate.

Definition at line 81 of file CdnCacheUpdate.php.

References purge(), and resolveReboundDelayByUrl().

◆ expand()

static CdnCacheUpdate::expand (   $url)
staticprivate

Expand local URLs to fully-qualified URLs using the internal protocol and host defined in $wgInternalServer.

Input that's already fully- qualified will be passed through unchanged.

This is used to generate purge URLs that may be either local to the main wiki or include a non-native host, such as images hosted on a second internal server.

Client functions should not need to call this.

Parameters
string$url
Returns
string

Definition at line 339 of file CdnCacheUpdate.php.

References PROTO_INTERNAL, and wfExpandUrl().

Referenced by HTCPPurge(), and naivePurge().

◆ getRuleForURL()

static CdnCacheUpdate::getRuleForURL (   $url,
  $rules 
)
staticprivate

Find the HTCP routing rule to use for a given URL.

Parameters
string$urlURL to match
array$rulesArray of rules, see $wgHTCPRouting for format and behavior
Returns
mixed Element of $rules that matched, or false if nothing matched

Definition at line 349 of file CdnCacheUpdate.php.

Referenced by HTCPPurge().

◆ getUrls()

CdnCacheUpdate::getUrls ( )
Returns
string[] List of URLs

Definition at line 156 of file CdnCacheUpdate.php.

References resolveReboundDelayByUrl().

◆ HTCPPurge()

static CdnCacheUpdate::HTCPPurge ( array  $urls)
staticprivate

Send Hyper Text Caching Protocol (HTCP) CLR requests.

Exceptions
MWException
Parameters
string[]$urlsCollection of URLs to purge

Definition at line 199 of file CdnCacheUpdate.php.

References $wgHTCPMulticastTTL, $wgHTCPRouting, expand(), getRuleForURL(), and wfDebugLog().

Referenced by purge().

◆ merge()

CdnCacheUpdate::merge ( MergeableUpdate  $update)

Merge this enqueued update with a new MergeableUpdate of the same qualified class name.

Parameters
MergeableUpdate$updateThe new update (having the same class)

Implements MergeableUpdate.

Definition at line 59 of file CdnCacheUpdate.php.

◆ naivePurge()

static CdnCacheUpdate::naivePurge ( array  $urls)
staticprivate

Send HTTP PURGE requests for each of the URLs to all of the cache servers.

Parameters
string[]$urls
Exceptions
Exception

Definition at line 295 of file CdnCacheUpdate.php.

References $wgCdnServers, expand(), MW_VERSION, and wfParseUrl().

Referenced by purge().

◆ newFromTitles()

static CdnCacheUpdate::newFromTitles (   $pages,
  $urls = [] 
)
static

Create an update object from an array of Title objects, or a TitleArray object.

Parameters
PageReference[]$pages
string[]$urls
Returns
CdnCacheUpdate
Deprecated:
Since 1.35 Use HtmlCacheUpdater instead

Definition at line 77 of file CdnCacheUpdate.php.

◆ purge()

static CdnCacheUpdate::purge ( array  $urls)
static

Purges a list of CDN nodes defined in $wgCdnServers.

$urlArr should contain the full URLs to purge as values (example: $urlArr[] = 'http://my.host/something')

Parameters
string[]$urlsList of full URLs to purge

Definition at line 114 of file CdnCacheUpdate.php.

References $wgCdnServers, $wgHTCPRouting, HTCPPurge(), naivePurge(), and wfDebugLog().

Referenced by BenchmarkPurge\benchCdn(), doUpdate(), and CdnPurgeJob\run().

◆ resolveReboundDelayByUrl()

CdnCacheUpdate::resolveReboundDelayByUrl ( )
private
Returns
int[] Map of (URL => rebound purge delay)

Definition at line 163 of file CdnCacheUpdate.php.

Referenced by doUpdate(), and getUrls().

Member Data Documentation

◆ $pageTuples

array [] CdnCacheUpdate::$pageTuples = []
private

List of (PageReference, rebound purge delay) tuples.

Definition at line 33 of file CdnCacheUpdate.php.

◆ $urlTuples

array [] CdnCacheUpdate::$urlTuples = []
private

List of (URL, rebound purge delay) tuples.

Definition at line 31 of file CdnCacheUpdate.php.


The documentation for this class was generated from the following file: