|
MediaWiki master
|
Page existence and metadata cache. More...
Inherits LoggerAwareInterface.

Public Member Functions | |
| __construct (TitleFormatter $titleFormatter, WANObjectCache $cache, NamespaceInfo $nsInfo, ?ILoadBalancer $loadBalancer=null) | |
| addBadLinkObj ( $page, int $queryFlags=IDBAccessObject::READ_NORMAL) | |
| Add information about a missing page to the process cache. | |
| addGoodLinkObjFromRow ( $page, stdClass $row, int $queryFlags=IDBAccessObject::READ_NORMAL) | |
| Add information about an existing page to the process cache. | |
| 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) | |
| Clear information about a page being missing from the process cache. | |
| clearLink ( $page) | |
| Clear information about a page from the process cache. | |
| getGoodLinkFieldObj ( $page, string $field) | |
| Get the field of a page known to the process cache. | |
| getGoodLinkID ( $page) | |
| Get the ID of a page known to the process cache. | |
| 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). | |
| invalidateTitle ( $page) | |
| Purge the persistent link cache for a title. | |
| isBadLink ( $page) | |
| Check if a page is known to be missing based on the process cache. | |
| setLogger (LoggerInterface $logger) | |
Static Public Member Functions | |
| static | getSelectFields () |
| Fields that LinkCache needs to select. | |
Page existence and metadata cache.
This is exists primarily to reduce heavy database load from the Parser when rendering each individual outgoing link and template transclusion when parsing wikitext.
See the architecture doc at docs/LinkCache.md for more information.
To create a batch, you can use the following code:
Definition at line 53 of file LinkCache.php.
| MediaWiki\Page\LinkCache::__construct | ( | TitleFormatter | $titleFormatter, |
| WANObjectCache | $cache, | ||
| NamespaceInfo | $nsInfo, | ||
| ?ILoadBalancer | $loadBalancer = null ) |
| TitleFormatter | $titleFormatter | |
| WANObjectCache | $cache | |
| NamespaceInfo | $nsInfo | |
| ILoadBalancer | null | $loadBalancer | Use null when no database is set up, for example on installation |
Definition at line 81 of file LinkCache.php.
| MediaWiki\Page\LinkCache::addBadLinkObj | ( | $page, | |
| int | $queryFlags = IDBAccessObject::READ_NORMAL ) |
Add information about a missing page to the process cache.
Callers must set the READ_LATEST flag if the row came from a DB_PRIMARY source. However, the use of such data is highly discouraged; most callers rely on seeing consistent DB_REPLICA data (e.g. REPEATABLE-READ point-in-time snapshots) and the accidental use of DB_PRIMARY data via LinkCache is prone to causing anomalies.
| 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. |
| int | $queryFlags | The query flags used to retrieve the row, IDBAccessObject::READ_* |
Definition at line 299 of file LinkCache.php.
| MediaWiki\Page\LinkCache::addGoodLinkObjFromRow | ( | $page, | |
| stdClass | $row, | ||
| int | $queryFlags = IDBAccessObject::READ_NORMAL ) |
Add information about an existing page to the process cache.
Callers must set the READ_LATEST flag if the row came from a DB_PRIMARY source. However, the use of such data is highly discouraged; most callers rely on seeing consistent DB_REPLICA data (e.g. REPEATABLE-READ point-in-time snapshots) and the accidental use of DB_PRIMARY data via LinkCache is prone to causing anomalies.
| 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_* |
Definition at line 266 of file LinkCache.php.
| MediaWiki\Page\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 382 of file LinkCache.php.
| MediaWiki\Page\LinkCache::clear | ( | ) |
Clears cache.
Definition at line 582 of file LinkCache.php.
| MediaWiki\Page\LinkCache::clearBadLink | ( | $page | ) |
Clear information about a page being missing from the process cache.
| 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 316 of file LinkCache.php.
| MediaWiki\Page\LinkCache::clearLink | ( | $page | ) |
Clear information about a page from the process cache.
| 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 336 of file LinkCache.php.
| MediaWiki\Page\LinkCache::getGoodLinkFieldObj | ( | $page, | |
| string | $field ) |
Get the field of a page known to the process 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' ) |
Definition at line 192 of file LinkCache.php.
| MediaWiki\Page\LinkCache::getGoodLinkID | ( | $page | ) |
Get the ID of a page known to the process cache.
| 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 164 of file LinkCache.php.
| MediaWiki\Page\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 ( IReadableDatabase $db, int $ns, string $dbkey, array $queryOptions ): ?stdObj. |
| int | $queryFlags | IDBAccessObject::READ_XXX |
Definition at line 477 of file LinkCache.php.
|
static |
Fields that LinkCache needs to select.
Definition at line 349 of file LinkCache.php.
References MediaWiki\MediaWikiServices\getInstance(), MediaWiki\MainConfigNames\PageLanguageUseDB, and MediaWiki\Page\PageStoreRecord\REQUIRED_FIELDS.
| MediaWiki\Page\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 570 of file LinkCache.php.
| MediaWiki\Page\LinkCache::isBadLink | ( | $page | ) |
Check if a page is known to be missing based on the process 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 239 of file LinkCache.php.
| MediaWiki\Page\LinkCache::setLogger | ( | LoggerInterface | $logger | ) |
Definition at line 95 of file LinkCache.php.