MediaWiki master
MediaWiki\Cache\BacklinkCache Class Reference

Class for fetching backlink lists, approximate backlink counts and partitions. More...

Public Member Functions

 __construct (ServiceOptions $options, LinksMigration $linksMigration, WANObjectCache $wanCache, HookContainer $hookContainer, IConnectionProvider $dbProvider, LoggerInterface $logger, PageReference $page)
 Create a new BacklinkCache.
 
 getCascadeProtectedLinkPages ()
 Get a PageIdentity iterator for cascade-protected template/file use backlinks.
 
 getLinkPages (string $table, $startId=false, $endId=false, $max=INF)
 Get the backlinks for a given table.
 
 getNumLinks ( $table)
 Get the approximate number of backlinks.
 
 getPage ()
 
 hasLinks ( $table)
 Check if there are any backlinks.
 
 partition ( $table, $batchSize)
 Partition the backlinks into batches.
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Detailed Description

Class for fetching backlink lists, approximate backlink counts and partitions.

This is a shared cache.

Instances of this class should typically be fetched with the method ::getBacklinkCache() from the BacklinkCacheFactory service.

Ideally you should only get your backlinks from here when you think there is some advantage in caching them. Otherwise, it's just a waste of memory.

Definition at line 63 of file BacklinkCache.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Cache\BacklinkCache::__construct ( ServiceOptions $options,
LinksMigration $linksMigration,
WANObjectCache $wanCache,
HookContainer $hookContainer,
IConnectionProvider $dbProvider,
LoggerInterface $logger,
PageReference $page )

Create a new BacklinkCache.

Parameters
ServiceOptions$options
LinksMigration$linksMigration
WANObjectCache$wanCache
HookContainer$hookContainer
IConnectionProvider$dbProvider
LoggerInterface$logger
PageReference$pagePage to create a backlink cache for

Definition at line 129 of file BacklinkCache.php.

References MediaWiki\Config\ServiceOptions\assertRequiredOptions().

Member Function Documentation

◆ getCascadeProtectedLinkPages()

MediaWiki\Cache\BacklinkCache::getCascadeProtectedLinkPages ( )

Get a PageIdentity iterator for cascade-protected template/file use backlinks.

Returns
Iterator<PageIdentity>
Since
1.37

Definition at line 527 of file BacklinkCache.php.

◆ getLinkPages()

MediaWiki\Cache\BacklinkCache::getLinkPages ( string $table,
$startId = false,
$endId = false,
$max = INF )

Get the backlinks for a given table.

Cached in process memory only.

Parameters
string$table
int | bool$startId
int | bool$endId
int | float$maxInteger, or INF for no max
Returns
Iterator<PageIdentity>
Since
1.37

Definition at line 174 of file BacklinkCache.php.

◆ getNumLinks()

MediaWiki\Cache\BacklinkCache::getNumLinks ( $table)

Get the approximate number of backlinks.

Parameters
string$table
Returns
int

Definition at line 375 of file BacklinkCache.php.

References getDB().

◆ getPage()

MediaWiki\Cache\BacklinkCache::getPage ( )
Since
1.37
Returns
PageReference

Definition at line 152 of file BacklinkCache.php.

◆ hasLinks()

MediaWiki\Cache\BacklinkCache::hasLinks ( $table)

Check if there are any backlinks.

Only use the process cache, since the WAN cache is potentially stale (T368006).

Parameters
string$table
Returns
bool

Definition at line 354 of file BacklinkCache.php.

◆ partition()

MediaWiki\Cache\BacklinkCache::partition ( $table,
$batchSize )

Partition the backlinks into batches.

Returns an array giving the start and end of each range. The first batch has a start of false, and the last batch has an end of false.

Parameters
string$tableThe links table name
int$batchSize
Returns
array

Definition at line 413 of file BacklinkCache.php.

References getDB().

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Cache\BacklinkCache::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const UpdateRowsPerJob
Name constant for the UpdateRowsPerJob setting, for use with Config::get()
Access: internal
Used by ServiceWiring.php

Definition at line 67 of file BacklinkCache.php.


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