Manual:ParserCache.php

Class for caching rendered output, i.e. HTML as well as associated data, for the latest revision of a page.

Main features

edit

For detailed information, see Manual:Parser cache. This is a summary:

  • supports 'varying keys', i.e. the use of different cache keys for a page or revision, based on certain 'options'.
  • because of this, supports the use of multiple ParserCache instances so that multiple cache entries can exist side by side (MW 1.36+).
  • consists of two tiers, each stored with its own key, to avoid cache fragmentation that may happen as a result of having multiple cache entries:
    • one containing a CacheTime object for holding metadata about cache expiration and parsing 'options'. Metadata can be retrieved using getMetadata().
    • another containing the ParserOutput object, with values from the options specified in the metadata of the first tier. It can be retrieved with getDirty() or get().
  • allows for cache to be created ('populated')
  • allows for cache to be removed/replaced:
    • after the revision timestamp is updated and the cache entry is invalidated (marked as 'dirty')
    • after it expires. The removal of expired entries is called 'pruning'. See also ParserOutput::updateCacheExpiry().
    • when there are reasons for enforcing it (e.g. cache optimisation), in which case the process of removal is called 'eviction'.

Instantiation

edit

MediaWikiServices::getInstance()->getParserCache()

Public methods

edit

Public methods not for internal use only include:

  • getDirty() - retrieve the ParserOutput from ParserCache, even if it is outdated.
  • get() - retrieve the ParserOutput from ParserCache; false if not found or outdated.
  • getMetadata() - return the ParserCache metadata about the given page considering the given options.
  • save() - store ParserCache object.
  • deleteOptionsKey()