MediaWiki  1.28.1
LinkCache Class Reference

Cache for article titles (prefixed DB keys) and ids linked from one source. More...

Collaboration diagram for LinkCache:

Public Member Functions

 __construct (TitleFormatter $titleFormatter, WANObjectCache $cache)
 
 addBadLinkObj (LinkTarget $target)
 
 addGoodLinkObj ($id, LinkTarget $target, $len=-1, $redir=null, $revision=0, $model=null, $lang=null)
 Add a link for the title to the link cache. More...
 
 addGoodLinkObjFromRow (LinkTarget $target, $row)
 Same as above with better interface. More...
 
 addLink ($title)
 Add a title to the link cache, return the page_id or zero if non-existent. More...
 
 addLinkObj (LinkTarget $nt)
 Add a title to the link cache, return the page_id or zero if non-existent. More...
 
 clear ()
 Clears cache. More...
 
 clearBadLink ($title)
 
 clearLink (LinkTarget $target)
 
 forUpdate ($update=null)
 General accessor to get/set whether the master DB should be used. More...
 
 getGoodLinkFieldObj (LinkTarget $target, $field)
 Get a field of a title object from cache. More...
 
 getGoodLinkID ($title)
 
 invalidateTitle (LinkTarget $title)
 Purge the link cache for a title. More...
 
 isBadLink ($title)
 

Static Public Member Functions

static getSelectFields ()
 Fields that LinkCache needs to select. More...
 
static singleton ()
 Get an instance of this class. More...
 

Public Attributes

const MAX_SIZE = 10000
 How many Titles to store. More...
 

Private Member Functions

 fetchPageRow (IDatabase $db, LinkTarget $nt)
 
 isCacheable (LinkTarget $title)
 

Private Attributes

HashBagOStuff $mBadLinks
 
bool $mForUpdate = false
 
HashBagOStuff $mGoodLinks
 
TitleFormatter $titleFormatter
 
WANObjectCache $wanCache
 

Detailed Description

Cache for article titles (prefixed DB keys) and ids linked from one source.

Definition at line 31 of file LinkCache.php.

Constructor & Destructor Documentation

LinkCache::__construct ( TitleFormatter  $titleFormatter,
WANObjectCache  $cache 
)

Definition at line 51 of file LinkCache.php.

References $cache, and $titleFormatter.

Member Function Documentation

LinkCache::addBadLinkObj ( LinkTarget  $target)
Parameters
LinkTarget$target

Definition at line 166 of file LinkCache.php.

References isBadLink().

Referenced by addLinkObj().

LinkCache::addGoodLinkObj (   $id,
LinkTarget  $target,
  $len = -1,
  $redir = null,
  $revision = 0,
  $model = null,
  $lang = null 
)

Add a link for the title to the link cache.

Parameters
int$idPage's ID
LinkTarget$target
int$lenText's length
int$redirWhether the page is a redirect
int$revisionLatest revision's ID
string | null$modelLatest revision's content model ID
string | null$langLanguage code of the page, if not the content language

Definition at line 130 of file LinkCache.php.

References $lang.

LinkCache::addGoodLinkObjFromRow ( LinkTarget  $target,
  $row 
)

Same as above with better interface.

Since
1.19
Parameters
LinkTarget$target
stdClass$rowObject which has the fields page_id, page_is_redirect, page_latest and page_content_model

Definition at line 151 of file LinkCache.php.

Referenced by addLinkObj().

LinkCache::addLink (   $title)

Add a title to the link cache, return the page_id or zero if non-existent.

Deprecated:
since 1.27, unused
Parameters
string$titlePrefixed DB key
Returns
int Page ID or zero

Definition at line 196 of file LinkCache.php.

References $title, addLinkObj(), and Title\newFromDBkey().

LinkCache::addLinkObj ( LinkTarget  $nt)
LinkCache::clear ( )

Clears cache.

Definition at line 317 of file LinkCache.php.

LinkCache::clearBadLink (   $title)
Parameters
string$titlePrefixed DB key

Definition at line 176 of file LinkCache.php.

References $title.

LinkCache::clearLink ( LinkTarget  $target)
Parameters
LinkTarget$target

Definition at line 183 of file LinkCache.php.

LinkCache::fetchPageRow ( IDatabase  $db,
LinkTarget  $nt 
)
private
LinkCache::forUpdate (   $update = null)

General accessor to get/set whether the master DB should be used.

This used to also set the FOR UPDATE option (locking the rows read in order to avoid link table inconsistency), which was later removed for performance on wikis with a high edit rate.

Parameters
bool$update
Returns
bool

Definition at line 78 of file LinkCache.php.

References wfSetVar().

LinkCache::getGoodLinkFieldObj ( LinkTarget  $target,
  $field 
)

Get a field of a title object from cache.

If this link is not a cached good title, it will return NULL.

Parameters
LinkTarget$target
string$field('length','redirect','revision','model')
Returns
string|int|null

Definition at line 101 of file LinkCache.php.

LinkCache::getGoodLinkID (   $title)
Parameters
string$titlePrefixed DB key
Returns
int Page ID or zero

Definition at line 86 of file LinkCache.php.

References $title.

Referenced by addLinkObj().

static LinkCache::getSelectFields ( )
static
LinkCache::invalidateTitle ( LinkTarget  $title)

Purge the link cache for a title.

Parameters
LinkTarget$title
Since
1.28

Definition at line 305 of file LinkCache.php.

References $cache, MediaWiki\Linker\LinkTarget\getDBkey(), ObjectCache\getMainWANInstance(), MediaWiki\Linker\LinkTarget\getNamespace(), and isCacheable().

LinkCache::isBadLink (   $title)
Parameters
string$titlePrefixed DB key
Returns
bool

Definition at line 114 of file LinkCache.php.

References $title.

Referenced by addBadLinkObj(), and addLinkObj().

LinkCache::isCacheable ( LinkTarget  $title)
private

Member Data Documentation

HashBagOStuff LinkCache::$mBadLinks
private

Definition at line 35 of file LinkCache.php.

bool LinkCache::$mForUpdate = false
private

Definition at line 40 of file LinkCache.php.

HashBagOStuff LinkCache::$mGoodLinks
private

Definition at line 33 of file LinkCache.php.

TitleFormatter LinkCache::$titleFormatter
private

Definition at line 43 of file LinkCache.php.

Referenced by __construct().

WANObjectCache LinkCache::$wanCache
private

Definition at line 37 of file LinkCache.php.

Referenced by addLinkObj().

const LinkCache::MAX_SIZE = 10000

How many Titles to store.

There are two caches, so the amount actually stored in memory can be up to twice this.

Definition at line 49 of file LinkCache.php.


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