MediaWiki
master
|
Cache for article titles (prefixed DB keys) and ids linked from one source. More...
Public Member Functions | |
__construct (TitleFormatter $titleFormatter, WANObjectCache $cache, NamespaceInfo $nsInfo=null, ILoadBalancer $loadBalancer=null) | |
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... | |
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) | |
getMutableCacheKeys (WANObjectCache $cache, LinkTarget $t) | |
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... | |
Private Member Functions | |
fetchPageRow (IDatabase $db, LinkTarget $nt) | |
isCacheable (LinkTarget $title) | |
Private Attributes | |
MapCacheLRU | $badLinks |
MapCacheLRU | $goodLinks |
ILoadBalancer null | $loadBalancer |
bool | $mForUpdate = false |
NamespaceInfo | $nsInfo |
TitleFormatter | $titleFormatter |
WANObjectCache | $wanCache |
const | MAX_SIZE = 10000 |
How many Titles to store. More... | |
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition at line 35 of file LinkCache.php.
LinkCache::__construct | ( | TitleFormatter | $titleFormatter, |
WANObjectCache | $cache, | ||
NamespaceInfo | $nsInfo = null , |
||
ILoadBalancer | $loadBalancer = null |
||
) |
TitleFormatter | $titleFormatter | |
WANObjectCache | $cache | |
NamespaceInfo | null | $nsInfo | Null for backward compatibility, but deprecated |
ILoadBalancer | null | $loadBalancer | Use null when no database is set up, for example on installation |
Definition at line 67 of file LinkCache.php.
References $cache, $loadBalancer, $nsInfo, $titleFormatter, and wfDeprecated().
LinkCache::addBadLinkObj | ( | LinkTarget | $target | ) |
LinkTarget | $target |
Definition at line 202 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.
int | $id | Page's ID |
LinkTarget | $target | |
int | $len | Text's length |
int | null | $redir | Whether the page is a redirect |
int | $revision | Latest revision's ID |
string | null | $model | Latest revision's content model ID |
string | null | $lang | Language code of the page, if not the content language |
Definition at line 158 of file LinkCache.php.
References $lang.
LinkCache::addGoodLinkObjFromRow | ( | LinkTarget | $target, |
$row | |||
) |
Same as above with better interface.
LinkTarget | $target | |
stdClass | $row | Object which has the fields page_id, page_is_redirect, page_latest and page_content_model |
Definition at line 180 of file LinkCache.php.
Referenced by addLinkObj().
LinkCache::addLinkObj | ( | LinkTarget | $nt | ) |
Add a title to the link cache, return the page_id or zero if non-existent.
LinkTarget | $nt | LinkTarget object to add |
Definition at line 256 of file LinkCache.php.
References $cache, $dbr, $wanCache, addBadLinkObj(), addGoodLinkObjFromRow(), DB_MASTER, DB_REPLICA, fetchPageRow(), MediaWiki\Linker\LinkTarget\getDBkey(), getGoodLinkID(), MediaWiki\Linker\LinkTarget\getNamespace(), isBadLink(), isCacheable(), MediaWiki\Linker\LinkTarget\isExternal(), and wfTimestamp().
LinkCache::clear | ( | ) |
Clears cache.
Definition at line 370 of file LinkCache.php.
LinkCache::clearBadLink | ( | $title | ) |
string | $title | Prefixed DB key |
Definition at line 212 of file LinkCache.php.
References $title.
LinkCache::clearLink | ( | LinkTarget | $target | ) |
LinkTarget | $target |
Definition at line 219 of file LinkCache.php.
|
private |
Definition at line 338 of file LinkCache.php.
References MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), getSelectFields(), isCacheable(), and Wikimedia\Rdbms\IDatabase\selectRow().
Referenced by addLinkObj().
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.
bool | null | $update |
Definition at line 106 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.
LinkTarget | $target | |
string | $field | ('length','redirect','revision','model') |
Definition at line 129 of file LinkCache.php.
LinkCache::getGoodLinkID | ( | $title | ) |
string | $title | Prefixed DB key |
Definition at line 114 of file LinkCache.php.
References $title.
Referenced by addLinkObj().
LinkCache::getMutableCacheKeys | ( | WANObjectCache | $cache, |
LinkTarget | $t | ||
) |
WANObjectCache | $cache | |
LinkTarget | $t |
Definition at line 317 of file LinkCache.php.
References $cache, $t, and isCacheable().
|
static |
Fields that LinkCache needs to select.
Definition at line 231 of file LinkCache.php.
References $wgPageLanguageUseDB.
Referenced by OutputPage\addCategoryLinksToLBAndGetResult(), CategoryViewer\doCategoryQuery(), LinkBatch\doQuery(), LinkHolderArray\doVariants(), fetchPageRow(), ApiPageSet\getPageTableFields(), LinkHolderArray\replaceInternal(), and SpecialPrefixindex\showPrefixChunk().
LinkCache::invalidateTitle | ( | LinkTarget | $title | ) |
Purge the link cache for a title.
LinkTarget | $title |
Definition at line 358 of file LinkCache.php.
References $cache, $title, $wanCache, and isCacheable().
LinkCache::isBadLink | ( | $title | ) |
string | $title | Prefixed DB key |
Definition at line 142 of file LinkCache.php.
References $title.
Referenced by addBadLinkObj(), and addLinkObj().
|
private |
Definition at line 325 of file LinkCache.php.
References $title, NS_CATEGORY, NS_FILE, NS_MEDIAWIKI, and NS_TEMPLATE.
Referenced by addLinkObj(), fetchPageRow(), getMutableCacheKeys(), and invalidateTitle().
|
static |
Get an instance of this class.
Definition at line 91 of file LinkCache.php.
|
private |
Definition at line 39 of file LinkCache.php.
|
private |
Definition at line 37 of file LinkCache.php.
|
private |
Definition at line 53 of file LinkCache.php.
Referenced by __construct().
|
private |
Definition at line 44 of file LinkCache.php.
|
private |
Definition at line 50 of file LinkCache.php.
Referenced by __construct().
|
private |
Definition at line 47 of file LinkCache.php.
Referenced by __construct().
|
private |
Definition at line 41 of file LinkCache.php.
Referenced by addLinkObj(), and invalidateTitle().
|
private |
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 59 of file LinkCache.php.