MediaWiki  1.27.2
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 ()
 
 addBadLinkObj (Title $title)
 
 addGoodLinkObj ($id, Title $title, $len=-1, $redir=null, $revision=0, $model=null, $lang=null)
 Add a link for the title to the link cache. More...
 
 addGoodLinkObjFromRow (Title $title, $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 (Title $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 (Title $title)
 
 forUpdate ($update=null)
 General accessor to get/set whether the master DB should be used. More...
 
 getGoodLinkFieldObj (Title $title, $field)
 Get a field of a title object from cache. More...
 
 getGoodLinkID ($title)
 
 isBadLink ($title)
 

Static Public Member Functions

static destroySingleton ()
 Destroy the singleton instance. More...
 
static setSingleton (LinkCache $instance)
 Set the singleton instance to a given object. More...
 
static singleton ()
 Get an instance of this class. More...
 

Public Attributes

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

Static Protected Attributes

static LinkCache $instance
 

Private Attributes

HashBagOStuff $mBadLinks
 
 $mForUpdate = false
 
HashBagOStuff $mGoodLinks
 

Detailed Description

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

Definition at line 29 of file LinkCache.php.

Constructor & Destructor Documentation

LinkCache::__construct ( )

Definition at line 51 of file LinkCache.php.

Member Function Documentation

LinkCache::addBadLinkObj ( Title  $title)
Parameters
Title$title

Definition at line 191 of file LinkCache.php.

References Title\getPrefixedDBkey(), and isBadLink().

Referenced by addLinkObj().

LinkCache::addGoodLinkObj (   $id,
Title  $title,
  $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
Title$title
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 155 of file LinkCache.php.

References $lang, and Title\getPrefixedDBkey().

LinkCache::addGoodLinkObjFromRow ( Title  $title,
  $row 
)

Same as above with better interface.

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

Definition at line 176 of file LinkCache.php.

References Title\getPrefixedDBkey().

Referenced by addLinkObj().

LinkCache::addLink (   $title)

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

Parameters
string$titlePrefixed DB key
Returns
int Page ID or zero

Definition at line 220 of file LinkCache.php.

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

LinkCache::addLinkObj ( Title  $nt)

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

Parameters
Title$ntTitle object to add
Returns
int Page ID or zero

Definition at line 234 of file LinkCache.php.

References $key, addBadLinkObj(), addGoodLinkObjFromRow(), DB_MASTER, DB_SLAVE, Title\getDBkey(), getGoodLinkID(), Title\getNamespace(), Title\getPrefixedDBkey(), global, isBadLink(), Title\isExternal(), and wfGetDB().

Referenced by addLink().

LinkCache::clear ( )

Clears cache.

Definition at line 280 of file LinkCache.php.

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

Definition at line 201 of file LinkCache.php.

References $title.

LinkCache::clearLink ( Title  $title)
Parameters
Title$title

Definition at line 208 of file LinkCache.php.

References Title\getPrefixedDBkey().

static LinkCache::destroySingleton ( )
static

Destroy the singleton instance.

A new one will be created next time singleton() is called.

Since
1.22

Definition at line 76 of file LinkCache.php.

Referenced by ContentHandlerTest\setUp(), and ContentHandlerTest\tearDown().

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 103 of file LinkCache.php.

References wfSetVar().

LinkCache::getGoodLinkFieldObj ( Title  $title,
  $field 
)

Get a field of a title object from cache.

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

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

Definition at line 126 of file LinkCache.php.

References Title\getPrefixedDBkey().

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

Definition at line 111 of file LinkCache.php.

References $title.

Referenced by addLinkObj().

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

Definition at line 139 of file LinkCache.php.

References $title.

Referenced by addBadLinkObj(), and addLinkObj().

static LinkCache::setSingleton ( LinkCache  $instance)
static

Set the singleton instance to a given object.

Since we do not have an interface for LinkCache, you have to be sure the given object implements all the LinkCache public methods.

Parameters
LinkCache$instance
Since
1.22

Definition at line 89 of file LinkCache.php.

References $instance.

Member Data Documentation

LinkCache LinkCache::$instance
staticprotected

Definition at line 49 of file LinkCache.php.

Referenced by setSingleton().

HashBagOStuff LinkCache::$mBadLinks
private

Definition at line 37 of file LinkCache.php.

LinkCache::$mForUpdate = false
private

Definition at line 38 of file LinkCache.php.

HashBagOStuff LinkCache::$mGoodLinks
private

Definition at line 33 of file LinkCache.php.

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 44 of file LinkCache.php.


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