MediaWiki REL1_35
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 update with $update.
 

Static Public Member Functions

static newFromTitles ( $titles, $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[] $titleTuples = []
 List of (Title, 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 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(), 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 335 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 345 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, expand(), MW_VERSION, 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: