MediaWiki  1.23.2
ParserCache Class Reference

Public Member Functions

 get ( $article, $popts, $useOutdated=false)
 Retrieve the ParserOutput from ParserCache. 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=true)
 Generates a key for caching the given article considering the given parser options. More...
 
 save ( $parserOutput, $page, $popts, $cacheTime=null, $revId=null)
 

Static Public Member Functions

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

Protected Member Functions

 __construct ( $memCached)
 Setup a cache pathway with a given back-end storage mechanism. More...
 
 getOptionsKey ( $article)
 
 getParserOutputKey ( $article, $hash)
 

Private Attributes

 $mMemc
 

Detailed Description

Todo:
document

Definition at line 28 of file ParserCache.php.

Constructor & Destructor Documentation

◆ __construct()

ParserCache::__construct (   $memCached)
protected

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

May be a memcached client or a BagOStuff derivative.

Parameters
$memCachedObject
Exceptions
MWException

Definition at line 51 of file ParserCache.php.

Member Function Documentation

◆ get()

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

Retrieve the ParserOutput from ParserCache.

false if not found or outdated.

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

Definition at line 180 of file ParserCache.php.

References $article, $value, getKey(), global, wfDebug(), wfIncrStats(), wfProfileIn(), and wfProfileOut().

◆ getDirty()

ParserCache::getDirty (   $article,
  $popts 
)

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

Parameters
$articleArticle
$poptsParserOptions
Returns
ParserOutput|bool False on failure

Definition at line 109 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
$articleArticle
$poptsParserOptions
Returns
string

Definition at line 97 of file ParserCache.php.

References $article, getParserOutputKey(), and ParserOptions\legacyOptions().

◆ getKey()

ParserCache::getKey (   $article,
  $popts,
  $useOutdated = true 
)

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.
Todo:
Document parameter $useOutdated
Parameters
Article$article
ParserOptions$popts
bool$useOutdated(default true)
Returns
bool|mixed|string

Definition at line 133 of file ParserCache.php.

References $article, getOptionsKey(), getParserOutputKey(), global, ParserOptions\legacyOptions(), ParserOptions\newFromUser(), wfDebug(), wfIncrStats(), and wfWarn().

Referenced by get().

◆ getOptionsKey()

ParserCache::getOptionsKey (   $article)
protected
Parameters
$articleArticle
Returns
mixed|string

Definition at line 78 of file ParserCache.php.

References $article, and wfMemcKey().

Referenced by getKey(), and save().

◆ getParserOutputKey()

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

Definition at line 63 of file ParserCache.php.

References $article, global, and wfMemcKey().

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

◆ save()

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

Definition at line 241 of file ParserCache.php.

References getOptionsKey(), getParserOutputKey(), CacheTime\updateCacheExpiry(), wfDebug(), and wfTimestampNow().

◆ singleton()

Member Data Documentation

◆ $mMemc

ParserCache::$mMemc
private

Definition at line 29 of file ParserCache.php.


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