MediaWiki REL1_37
|
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 ( $page) | |
addGoodLinkObj ( $id, $page, $len=-1, $redir=null, $revision=0, $model=null, $lang=null) | |
Add information about an existing page to the cache. | |
addGoodLinkObjFromRow ( $page, stdClass $row, int $queryFlags=IDBAccessObject::READ_NORMAL) | |
Same as above with better interface. | |
addLinkObj ( $page, int $queryFlags=IDBAccessObject::READ_NORMAL) | |
Add a title to the link cache, return the page_id or zero if non-existent. | |
clear () | |
Clears cache. | |
clearBadLink ( $page) | |
clearLink ( $page) | |
forUpdate ( $update=null) | |
General accessor to get/set whether the primary DB should be used. | |
getGoodLinkFieldObj ( $page, string $field) | |
Get a field of a page from the cache. | |
getGoodLinkID ( $page) | |
Returns the ID of the given page, if information about this page has been cached. | |
getGoodLinkRow (int $ns, string $dbkey, callable $fetchCallback=null, int $queryFlags=IDBAccessObject::READ_NORMAL) | |
Returns the row for the page if the page exists (subject to race conditions). | |
getMutableCacheKeys (WANObjectCache $cache, $page) | |
invalidateTitle ( $page) | |
Purge the persistent link cache for a title. | |
isBadLink ( $page) | |
Returns true if the fact that this page does not exist had been added to the cache. | |
setLogger (LoggerInterface $logger) | |
Static Public Member Functions | |
static | getSelectFields () |
Fields that LinkCache needs to select. | |
static | singleton () |
Get an instance of this class. | |
Private Member Functions | |
fetchPageRow (IDatabase $db, int $ns, string $dbkey, $options=[]) | |
getCacheKey ( $page, $passThrough=false) | |
getGoodLinkRowInternal (?TitleValue $link, callable $fetchCallback=null, int $queryFlags=IDBAccessObject::READ_NORMAL) | |
usePersistentCache ( $pageOrNamespace) | |
Private Attributes | |
MapCacheLRU | $badLinks |
MapCacheLRU | $goodLinks |
ILoadBalancer null | $loadBalancer |
LoggerInterface | $logger |
bool | $mForUpdate = false |
NamespaceInfo | $nsInfo |
TitleFormatter | $titleFormatter |
WANObjectCache | $wanCache |
const | MAX_SIZE = 10000 |
How many Titles to store. | |
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition at line 41 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 76 of file LinkCache.php.
References $cache, $loadBalancer, and wfDeprecated().
LinkCache::addBadLinkObj | ( | $page | ) |
LinkTarget | PageReference | array | $page | The page to set cached info for. Can be given as an object or an associative array containing the page_namespace and page_title fields. In MediaWiki 1.36 and earlier, only LinkTarget was accepted. |
Definition at line 352 of file LinkCache.php.
References getCacheKey(), and isBadLink().
LinkCache::addGoodLinkObj | ( | $id, | |
$page, | |||
$len = -1 , |
|||
$redir = null , |
|||
$revision = 0 , |
|||
$model = null , |
|||
$lang = null |
|||
) |
Add information about an existing page to the cache.
int | $id | Page's ID |
LinkTarget | PageReference | $page | The page to set cached info for. In MediaWiki 1.36 and earlier, only LinkTarget was accepted. |
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 295 of file LinkCache.php.
References $lang, and addGoodLinkObjFromRow().
LinkCache::addGoodLinkObjFromRow | ( | $page, | |
stdClass | $row, | ||
int | $queryFlags = IDBAccessObject::READ_NORMAL |
||
) |
Same as above with better interface.
LinkTarget | PageReference | array | $page | The page to set cached info for. Can be given as an object or an associative array containing the page_namespace and page_title fields. In MediaWiki 1.36 and earlier, only LinkTarget was accepted. |
stdClass | $row | Object which has all fields returned by getSelectFields(). |
int | $queryFlags | The query flags used to retrieve the row, IDBAccessObject::READ_XXX |
Definition at line 326 of file LinkCache.php.
References getCacheKey().
Referenced by addGoodLinkObj().
LinkCache::addLinkObj | ( | $page, | |
int | $queryFlags = IDBAccessObject::READ_NORMAL |
||
) |
Add a title to the link cache, return the page_id or zero if non-existent.
This causes the link to be looked up in the database if it is not yet cached.
LinkTarget | PageReference | array | $page | The page to load. Can be given as an object or an associative array containing the page_namespace and page_title fields. In MediaWiki 1.36 and earlier, only LinkTarget was accepted. |
int | $queryFlags | IDBAccessObject::READ_XXX |
Definition at line 428 of file LinkCache.php.
References getGoodLinkRow().
LinkCache::clear | ( | ) |
Clears cache.
Definition at line 643 of file LinkCache.php.
LinkCache::clearBadLink | ( | $page | ) |
LinkTarget | PageReference | array | string | $page | The page to clear cached info for, as an object, an array containing the page_namespace and page_title fields, or a prefixed DB key. In MediaWiki 1.36 and earlier, only a string was accepted. In MediaWiki 1.36 and earlier, only a string was accepted. |
Definition at line 366 of file LinkCache.php.
References getCacheKey().
LinkCache::clearLink | ( | $page | ) |
LinkTarget | PageReference | array | $page | The page to clear cached info for. Can be given as an object or an associative array containing the page_namespace and page_title fields. In MediaWiki 1.36 and earlier, only LinkTarget was accepted. |
Definition at line 380 of file LinkCache.php.
References getCacheKey().
|
private |
IDatabase | $db | |
int | $ns | |
string | $dbkey | |
array | $options | Query options, see IDatabase::select() for details. |
Definition at line 607 of file LinkCache.php.
References Wikimedia\Rdbms\IDatabase\selectRow().
LinkCache::forUpdate | ( | $update = null | ) |
General accessor to get/set whether the primary 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 125 of file LinkCache.php.
References wfDeprecated(), and wfSetVar().
|
private |
LinkTarget | PageReference | array | string | $page | |
bool | $passThrough | Return $page if $page is a string |
Definition at line 136 of file LinkCache.php.
References MediaWiki\Page\PageIdentity\canExist(), and MediaWiki\Page\PageReference\getWikiId().
Referenced by addBadLinkObj(), addGoodLinkObjFromRow(), clearBadLink(), clearLink(), getGoodLinkFieldObj(), getGoodLinkID(), getGoodLinkRowInternal(), and isBadLink().
LinkCache::getGoodLinkFieldObj | ( | $page, | |
string | $field | ||
) |
Get a field of a page from the cache.
If this link is not a cached good title, it will return NULL.
LinkTarget | PageReference | array | $page | The page to get cached info for. Can be given as an object or an associative array containing the page_namespace and page_title fields. In MediaWiki 1.36 and earlier, only LinkTarget was accepted. |
string | $field | ( 'id', 'length', 'redirect', 'revision', 'model', 'lang', 'restrictions' ) |
Definition at line 220 of file LinkCache.php.
References getCacheKey(), and isBadLink().
LinkCache::getGoodLinkID | ( | $page | ) |
Returns the ID of the given page, if information about this page has been cached.
LinkTarget | PageReference | array | string | $page | The page to get the ID for, as an object, an array containing the page_namespace and page_title fields, or a prefixed DB key. In MediaWiki 1.36 and earlier, only a string was accepted. |
Definition at line 196 of file LinkCache.php.
References getCacheKey().
LinkCache::getGoodLinkRow | ( | int | $ns, |
string | $dbkey, | ||
callable | $fetchCallback = null , |
||
int | $queryFlags = IDBAccessObject::READ_NORMAL |
||
) |
Returns the row for the page if the page exists (subject to race conditions).
The row will be returned from local cache or WAN cache if possible, or it will be looked up using the callback provided.
int | $ns | |
string | $dbkey | |
callable | null | $fetchCallback | A callback that will retrieve the link row with the signature ( IDatabase $db, int $ns, string $dbkey, array $queryOptions ): ?stdObj. |
int | $queryFlags | IDBAccessObject::READ_XXX |
Definition at line 522 of file LinkCache.php.
Referenced by addLinkObj().
|
private |
TitleValue | null | $link | |
callable | null | $fetchCallback | |
int | $queryFlags |
Definition at line 447 of file LinkCache.php.
References getCacheKey().
LinkCache::getMutableCacheKeys | ( | WANObjectCache | $cache, |
$page | |||
) |
WANObjectCache | $cache | |
LinkTarget | Pagereference | $page | In MediaWiki 1.36 and earlier, only LinkTarget was accepted. |
Definition at line 567 of file LinkCache.php.
References $cache.
|
static |
Fields that LinkCache needs to select.
Definition at line 395 of file LinkCache.php.
References $wgPageLanguageUseDB.
LinkCache::invalidateTitle | ( | $page | ) |
Purge the persistent link cache for a title.
LinkTarget | PageReference | $page | In MediaWiki 1.36 and earlier, only LinkTarget was accepted. |
Definition at line 629 of file LinkCache.php.
References $cache.
LinkCache::isBadLink | ( | $page | ) |
Returns true if the fact that this page does not exist had been added to the cache.
LinkTarget | PageReference | array | string | $page | The page to get cached info for, as an object, an array containing the page_namespace and page_title fields, or a prefixed DB key. In MediaWiki 1.36 and earlier, only a string was accepted. In MediaWiki 1.36 and earlier, only a string was accepted. |
Definition at line 271 of file LinkCache.php.
References getCacheKey().
Referenced by addBadLinkObj(), and getGoodLinkFieldObj().
LinkCache::setLogger | ( | LoggerInterface | $logger | ) |
LoggerInterface | $logger |
Definition at line 98 of file LinkCache.php.
|
static |
Get an instance of this class.
Definition at line 109 of file LinkCache.php.
References wfDeprecated().
|
private |
LinkTarget | PageReference | int | $pageOrNamespace |
Definition at line 586 of file LinkCache.php.
References NS_CATEGORY, NS_FILE, NS_MEDIAWIKI, and NS_TEMPLATE.
|
private |
Definition at line 45 of file LinkCache.php.
|
private |
Definition at line 43 of file LinkCache.php.
|
private |
Definition at line 59 of file LinkCache.php.
Referenced by __construct().
|
private |
Definition at line 62 of file LinkCache.php.
|
private |
Definition at line 50 of file LinkCache.php.
|
private |
Definition at line 56 of file LinkCache.php.
|
private |
Definition at line 53 of file LinkCache.php.
|
private |
Definition at line 47 of file LinkCache.php.
|
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 68 of file LinkCache.php.