MediaWiki fundraising/REL1_35
ParserCache Class Reference
Collaboration diagram for ParserCache:

Public Member Functions

 __construct (BagOStuff $cache, $cacheEpoch='20030516000000', HookContainer $hookContainer=null, IBufferingStatsdDataFactory $stats=null)
 Setup a cache pathway with a given back-end storage mechanism.
 
 deleteOptionsKey (WikiPage $wikiPage)
 
 get (Page $wikiPage, $popts, $useOutdated=false)
 Retrieve the ParserOutput from ParserCache.
 
 getCacheStorage ()
 Get the backend BagOStuff instance that powers the parser cache.
 
 getDirty (WikiPage $wikiPage, $popts)
 Retrieve the ParserOutput from ParserCache, even if it's outdated.
 
 getETag (WikiPage $wikiPage, $popts)
 Provides an E-Tag suitable for the whole page.
 
 getKey (WikiPage $wikiPage, $popts, $useOutdated=self::USE_ANYTHING)
 Generates a key for caching the given page considering the given parser options.
 
 save (ParserOutput $parserOutput, WikiPage $wikiPage, $popts, $cacheTime=null, $revId=null)
 

Static Public Member Functions

static singleton ()
 Get an instance of this object.
 

Protected Member Functions

 getOptionsKey (WikiPage $wikiPage)
 
 getParserOutputKey (WikiPage $wikiPage, $hash)
 

Private Member Functions

 incrementStats (WikiPage $wikiPage, $metricSuffix)
 

Private Attributes

BagOStuff $cache
 
string $cacheEpoch
 Anything cached prior to this is invalidated.
 
HookRunner $hookRunner
 
IBufferingStatsdDataFactory $stats
 
const USE_ANYTHING = 3
 Use expired data and data from different revisions, and if all else fails vary on all variable options.
 
const USE_CURRENT_ONLY = 0
 Constants for self::getKey()
 
const USE_EXPIRED = 1
 Use expired data if current data is unavailable.
 
const USE_OUTDATED = 2
 Use expired data or data from different revisions if current data is unavailable.
 

Detailed Description

Todo
document

Definition at line 32 of file ParserCache.php.

Constructor & Destructor Documentation

◆ __construct()

ParserCache::__construct ( BagOStuff $cache,
$cacheEpoch = '20030516000000',
HookContainer $hookContainer = null,
IBufferingStatsdDataFactory $stats = null )

Setup a cache pathway with a given back-end storage mechanism.

This class use an invalidation strategy that is compatible with MultiWriteBagOStuff in async replication mode.

Parameters
BagOStuff$cache
string$cacheEpochAnything before this timestamp is invalidated
HookContainer | null$hookContainer
IBufferingStatsdDataFactory | null$stats
Exceptions
MWException

Definition at line 92 of file ParserCache.php.

References $cache.

Member Function Documentation

◆ deleteOptionsKey()

ParserCache::deleteOptionsKey ( WikiPage $wikiPage)
Parameters
WikiPage$wikiPage
Since
1.28

Definition at line 134 of file ParserCache.php.

References getOptionsKey().

◆ get()

ParserCache::get ( Page $wikiPage,
$popts,
$useOutdated = false )

Retrieve the ParserOutput from ParserCache.

false if not found or outdated.

Parameters
WikiPage | Article | Page$wikiPageArticle is hard deprecated since 1.35
ParserOptions$popts
bool$useOutdated(default false)
Returns
ParserOutput|bool False on failure

Definition at line 267 of file ParserCache.php.

References getKey(), incrementStats(), wfDebug(), wfDebugLog(), and wfDeprecated().

◆ getCacheStorage()

ParserCache::getCacheStorage ( )

Get the backend BagOStuff instance that powers the parser cache.

Since
1.30
Returns
BagOStuff

Definition at line 409 of file ParserCache.php.

References $cache.

◆ getDirty()

ParserCache::getDirty ( WikiPage $wikiPage,
$popts )

Retrieve the ParserOutput from ParserCache, even if it's outdated.

Parameters
WikiPage$wikiPage
ParserOptions$popts
Returns
ParserOutput|bool False on failure

Definition at line 170 of file ParserCache.php.

References true.

Referenced by RefreshLinksJob\getParserOutputFromCache().

◆ getETag()

ParserCache::getETag ( WikiPage $wikiPage,
$popts )

Provides an E-Tag suitable for the whole page.

Note that $wikiPage is just the main wikitext. The E-Tag has to be unique to the whole page, even if the article itself is the same, so it uses the complete set of user options. We don't want to use the preference of a different user on a message just because it wasn't used in $wikiPage. For example give a Chinese interface to a user with English preferences. That's why we take into account all user options. (r70809 CR)

Parameters
WikiPage$wikiPage
ParserOptions$popts
Returns
string

Definition at line 152 of file ParserCache.php.

References getParserOutputKey(), WikiPage\getTitle(), and WikiPage\getTouched().

◆ getKey()

ParserCache::getKey ( WikiPage $wikiPage,
$popts,
$useOutdated = self::USE_ANYTHING )

Generates a key for caching the given page considering the given parser options.

Note
Which parser options influence the cache key is controlled via ParserOutput::recordOption() or ParserOptions::addExtraKey().
Used by Article to provide a unique id for the PoolCounter. It would be preferable to have this code in get() instead of having Article looking in our internals.
Parameters
WikiPage$wikiPage
ParserOptions$popts
int | bool$useOutdatedOne of the USE constants. For backwards compatibility, boolean false is treated as USE_CURRENT_ONLY and boolean true is treated as USE_ANYTHING.
Returns
bool|mixed|string
Since
1.30 Changed $useOutdated to an int and added the non-boolean values

Definition at line 205 of file ParserCache.php.

References WikiPage\getLatest(), getOptionsKey(), getParserOutputKey(), WikiPage\getTitle(), WikiPage\getTouched(), incrementStats(), wfDebug(), wfDebugLog(), and wfWarn().

Referenced by get().

◆ getOptionsKey()

ParserCache::getOptionsKey ( WikiPage $wikiPage)
protected
Parameters
WikiPage$wikiPage
Returns
mixed|string

Definition at line 126 of file ParserCache.php.

References WikiPage\getId().

Referenced by deleteOptionsKey(), getKey(), and save().

◆ getParserOutputKey()

ParserCache::getParserOutputKey ( WikiPage $wikiPage,
$hash )
protected
Parameters
WikiPage$wikiPage
string$hash
Returns
mixed|string

Definition at line 111 of file ParserCache.php.

References $wgRequest, and WikiPage\getId().

Referenced by getETag(), getKey(), and save().

◆ incrementStats()

ParserCache::incrementStats ( WikiPage $wikiPage,
$metricSuffix )
private
Parameters
WikiPage$wikiPage
string$metricSuffix

Definition at line 179 of file ParserCache.php.

References WikiPage\getContentModel().

Referenced by get(), and getKey().

◆ save()

ParserCache::save ( ParserOutput $parserOutput,
WikiPage $wikiPage,
$popts,
$cacheTime = null,
$revId = null )

◆ singleton()

static ParserCache::singleton ( )
static

Get an instance of this object.

Deprecated
since 1.30, use MediaWikiServices instead
Returns
ParserCache

Definition at line 75 of file ParserCache.php.

References wfDeprecated().

Member Data Documentation

◆ $cache

BagOStuff ParserCache::$cache
private

Definition at line 54 of file ParserCache.php.

◆ $cacheEpoch

string ParserCache::$cacheEpoch
private

Anything cached prior to this is invalidated.

Definition at line 61 of file ParserCache.php.

◆ $hookRunner

HookRunner ParserCache::$hookRunner
private

Definition at line 64 of file ParserCache.php.

◆ $stats

IBufferingStatsdDataFactory ParserCache::$stats
private

Definition at line 67 of file ParserCache.php.

◆ USE_ANYTHING

const ParserCache::USE_ANYTHING = 3
private

Use expired data and data from different revisions, and if all else fails vary on all variable options.

Definition at line 51 of file ParserCache.php.

◆ USE_CURRENT_ONLY

const ParserCache::USE_CURRENT_ONLY = 0
private

Constants for self::getKey()

Since
1.30 Use only current data

Definition at line 39 of file ParserCache.php.

◆ USE_EXPIRED

const ParserCache::USE_EXPIRED = 1
private

Use expired data if current data is unavailable.

Definition at line 42 of file ParserCache.php.

◆ USE_OUTDATED

const ParserCache::USE_OUTDATED = 2
private

Use expired data or data from different revisions if current data is unavailable.

Definition at line 45 of file ParserCache.php.


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