MediaWiki  1.32.5
ParserCache Class Reference
Collaboration diagram for ParserCache:

Public Member Functions

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

Static Public Member Functions

static singleton ()
 Get an instance of this object. More...
 

Public Attributes

const USE_ANYTHING = 3
 Use expired data and data from different revisions, and if all else fails vary on all variable options. More...
 
const USE_CURRENT_ONLY = 0
 Constants for self::getKey() More...
 
const USE_EXPIRED = 1
 Use expired data if current data is unavailable. More...
 
const USE_OUTDATED = 2
 Use expired data or data from different revisions if current data is unavailable. More...
 

Protected Member Functions

 getOptionsKey ( $page)
 
 getParserOutputKey ( $article, $hash)
 

Private Attributes

string $cacheEpoch
 Anything cached prior to this is invalidated. More...
 
BagOStuff $mMemc
 

Detailed Description

Todo:
document

Definition at line 30 of file ParserCache.php.

Constructor & Destructor Documentation

◆ __construct()

ParserCache::__construct ( BagOStuff  $cache,
  $cacheEpoch = '20030516000000' 
)

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
Exceptions
MWException

Definition at line 80 of file ParserCache.php.

References $cache, and $cacheEpoch.

Member Function Documentation

◆ deleteOptionsKey()

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

Definition at line 113 of file ParserCache.php.

References getOptionsKey().

◆ get()

ParserCache::get (   $article,
  $popts,
  $useOutdated = false 
)

Retrieve the ParserOutput from ParserCache.

false if not found or outdated.

Parameters
WikiPage | Article$article
ParserOptions$popts
bool$useOutdated(default false)
Returns
ParserOutput|bool False on failure

Definition at line 228 of file ParserCache.php.

References $article, $value, getKey(), BagOStuff\READ_VERIFIED, Hooks\run(), wfDebug(), wfDebugLog(), and wfIncrStats().

◆ getCacheStorage()

ParserCache::getCacheStorage ( )

Get the backend BagOStuff instance that powers the parser cache.

Since
1.30
Returns
BagOStuff

Definition at line 361 of file ParserCache.php.

References $mMemc.

◆ getDirty()

ParserCache::getDirty (   $article,
  $popts 
)

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

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

Definition at line 143 of file ParserCache.php.

References $article, $value, and true.

◆ getETag()

ParserCache::getETag (   $article,
  $popts 
)

Provides an E-Tag suitable for the whole page.

Note that $article 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 $article. 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$article
ParserOptions$popts
Returns
string

Definition at line 131 of file ParserCache.php.

References $article, ParserOptions\allCacheVaryingOptions(), getParserOutputKey(), and ContextSource\getTitle().

◆ getKey()

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

Generates a key for caching the given article 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$article
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 168 of file ParserCache.php.

References $article, ParserOptions\allCacheVaryingOptions(), getOptionsKey(), getParserOutputKey(), ContextSource\getTitle(), ParserOptions\newFromUser(), BagOStuff\READ_VERIFIED, USE_ANYTHING, USE_CURRENT_ONLY, wfDebug(), wfDebugLog(), wfIncrStats(), and wfWarn().

Referenced by get().

◆ getOptionsKey()

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

Definition at line 105 of file ParserCache.php.

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

◆ getParserOutputKey()

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

Definition at line 90 of file ParserCache.php.

References $article, and $wgRequest.

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

◆ save()

ParserCache::save ( ParserOutput  $parserOutput,
  $page,
  $popts,
  $cacheTime = null,
  $revId = null 
)
Parameters
ParserOutput$parserOutput
WikiPage$page
ParserOptions$popts
string | null$cacheTimeTS_MW timestamp when the cache was generated
int | null$revIdRevision ID that was parsed

Definition at line 297 of file ParserCache.php.

References CacheTime\getCacheExpiry(), getOptionsKey(), getParserOutputKey(), ParserOutput\getUsedOptions(), ParserOutput\hasText(), Hooks\run(), CacheTime\setCacheRevisionId(), CacheTime\setCacheTime(), ParserOutput\setTimestamp(), wfDebug(), and wfTimestampNow().

◆ singleton()

static ParserCache::singleton ( )
static

Get an instance of this object.

Deprecated:
since 1.30, use MediaWikiServices instead
Returns
ParserCache

Definition at line 66 of file ParserCache.php.

Member Data Documentation

◆ $cacheEpoch

string ParserCache::$cacheEpoch
private

Anything cached prior to this is invalidated.

Definition at line 59 of file ParserCache.php.

Referenced by __construct().

◆ $mMemc

BagOStuff ParserCache::$mMemc
private

Definition at line 52 of file ParserCache.php.

Referenced by getCacheStorage().

◆ USE_ANYTHING

const ParserCache::USE_ANYTHING = 3

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

Definition at line 49 of file ParserCache.php.

Referenced by getKey().

◆ USE_CURRENT_ONLY

const ParserCache::USE_CURRENT_ONLY = 0

Constants for self::getKey()

Since
1.30 Use only current data

Definition at line 37 of file ParserCache.php.

Referenced by getKey().

◆ USE_EXPIRED

const ParserCache::USE_EXPIRED = 1

Use expired data if current data is unavailable.

Definition at line 40 of file ParserCache.php.

◆ USE_OUTDATED

const ParserCache::USE_OUTDATED = 2

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

Definition at line 43 of file ParserCache.php.


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