MediaWiki  master
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. More...
 
 getUrls ()
 
 merge (MergeableUpdate $update)
 Merge this update with $update. More...
 

Static Public Member Functions

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

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. More...
 
static getRuleForURL ( $url, $rules)
 Find the HTCP routing rule to use for a given URL. More...
 
static HTCPPurge (array $urls)
 Send Hyper Text Caching Protocol (HTCP) CLR requests. More...
 
static naivePurge (array $urls)
 Send HTTP PURGE requests for each of the URLs to all of the cache servers. More...
 

Private Attributes

array[] $titleTuples = []
 List of (Title, rebound purge delay) tuples. More...
 
array[] $urlTuples = []
 List of (URL, rebound purge delay) tuples. More...
 

Detailed Description

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

Definition at line 28 of file CdnCacheUpdate.php.

Constructor & Destructor Documentation

◆ __construct()

CdnCacheUpdate::__construct ( array  $targets,
array  $options = [] 
)
Parameters
string[] | Title[]$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 43 of file CdnCacheUpdate.php.

Member Function Documentation

◆ doUpdate()

CdnCacheUpdate::doUpdate ( )

Perform the actual work.

Implements DeferrableUpdate.

Definition at line 79 of file CdnCacheUpdate.php.

References purge(), resolveReboundDelayByUrl(), and JobQueueGroup\singleton().

◆ 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 337 of file CdnCacheUpdate.php.

References PROTO_INTERNAL, and wfExpandUrl().

Referenced by HTCPPurge().

◆ 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 347 of file CdnCacheUpdate.php.

Referenced by HTCPPurge().

◆ getUrls()

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

Definition at line 154 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 195 of file CdnCacheUpdate.php.

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

Referenced by purge().

◆ merge()

CdnCacheUpdate::merge ( MergeableUpdate  $update)

Merge this update with $update.

Parameters
MergeableUpdate$updateUpdate of the same class type

Implements MergeableUpdate.

Definition at line 58 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 291 of file CdnCacheUpdate.php.

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

Referenced by purge().

◆ newFromTitles()

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

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

Parameters
Traversable | Title[]$titles
string[]$urls
Returns
CdnCacheUpdate
Deprecated:
Since 1.35 Use HtmlCacheUpdater instead

Definition at line 75 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 112 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 161 of file CdnCacheUpdate.php.

References $title.

Referenced by doUpdate(), and getUrls().

Member Data Documentation

◆ $titleTuples

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

List of (Title, rebound purge delay) tuples.

Definition at line 32 of file CdnCacheUpdate.php.

◆ $urlTuples

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

List of (URL, rebound purge delay) tuples.

Definition at line 30 of file CdnCacheUpdate.php.


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