MediaWiki REL1_39
|
Class for fetching backlink lists, approximate backlink counts and partitions. More...
Public Member Functions | |
__construct (WANObjectCache $wanCache, PageReference $page) | |
Create a new BacklinkCache. | |
clear () | |
Clear locally stored data and database object. | |
getCascadeProtectedLinkPages () | |
Get a PageIdentity iterator for cascade-protected template/file use backlinks. | |
getCascadeProtectedLinks () | |
Get a Title iterator for cascade-protected template/file use backlinks. | |
getLinkPages (string $table, $startId=false, $endId=false, $max=INF) | |
Get the backlinks for a given table. | |
getLinks ( $table, $startId=false, $endId=false, $max=INF) | |
Get the backlinks for a given table. | |
getNumLinks ( $table, $max=INF) | |
Get the approximate number of backlinks. | |
getPage () | |
hasLinks ( $table) | |
Check if there are any backlinks. | |
partition ( $table, $batchSize) | |
Partition the backlinks into batches. | |
setDB ( $db) | |
Set the Database object to use. | |
Static Public Member Functions | |
static | get (PageReference $page) |
Create a new BacklinkCache or reuse any existing one. | |
Protected Member Functions | |
getConditions ( $table) | |
Get the SQL condition array for selecting backlinks, with a join on the page table. | |
getDB () | |
Get the replica DB connection to the database When non existing, will initialize the connection. | |
getPrefix ( $table) | |
Get the field name prefix for a given table. | |
partitionResult ( $res, $batchSize, $isComplete=true) | |
Partition a DB result with backlinks in it into batches. | |
queryLinks ( $table, $startId, $endId, $max, $select='all') | |
Get the backlinks for a given table. | |
Protected Attributes | |
$db | |
Local copy of a database object. | |
IResultWrapper[] | $fullResultCache = [] |
Contains the whole links from a database result. | |
PageReference | $page |
Local copy of a PageReference object. | |
array[] | $partitionCache = [] |
Multi dimensions array representing batches. | |
WANObjectCache | $wanCache |
Static Protected Attributes | |
static BacklinkCache | $instance |
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.
Introduced by r47317
Definition at line 51 of file BacklinkCache.php.
BacklinkCache::__construct | ( | WANObjectCache | $wanCache, |
PageReference | $page ) |
Create a new BacklinkCache.
WANObjectCache | $wanCache | |
PageReference | $page | Page to create a backlink cache for |
Definition at line 107 of file BacklinkCache.php.
BacklinkCache::clear | ( | ) |
Clear locally stored data and database object.
Invalidate data in memcache.
Definition at line 139 of file BacklinkCache.php.
|
static |
Create a new BacklinkCache or reuse any existing one.
Currently, only one cache instance can exist; callers that need multiple backlink cache objects should keep them in scope.
PageReference | $page | Page to get a backlink cache for |
Definition at line 122 of file BacklinkCache.php.
BacklinkCache::getCascadeProtectedLinkPages | ( | ) |
Get a PageIdentity iterator for cascade-protected template/file use backlinks.
Definition at line 558 of file BacklinkCache.php.
BacklinkCache::getCascadeProtectedLinks | ( | ) |
Get a Title iterator for cascade-protected template/file use backlinks.
Definition at line 574 of file BacklinkCache.php.
References TitleArray\newFromResult().
|
protected |
Get the SQL condition array for selecting backlinks, with a join on the page table.
string | $table |
MWException |
Definition at line 303 of file BacklinkCache.php.
|
protected |
Get the replica DB connection to the database When non existing, will initialize the connection.
Definition at line 160 of file BacklinkCache.php.
References DB_REPLICA, and wfGetDB().
BacklinkCache::getLinkPages | ( | string | $table, |
$startId = false, | |||
$endId = false, | |||
$max = INF ) |
Get the backlinks for a given table.
Cached in process memory only.
string | $table | |
int | bool | $startId | |
int | bool | $endId | |
int | float | $max | Integer, or INF for no max |
Definition at line 177 of file BacklinkCache.php.
BacklinkCache::getLinks | ( | $table, | |
$startId = false, | |||
$endId = false, | |||
$max = INF ) |
Get the backlinks for a given table.
Cached in process memory only.
string | $table | |
int | bool | $startId | |
int | bool | $endId | |
int | float | $max | Integer, or INF for no max |
Definition at line 198 of file BacklinkCache.php.
References TitleArray\newFromResult().
BacklinkCache::getNumLinks | ( | $table, | |
$max = INF ) |
Get the approximate number of backlinks.
string | $table | |
int | float | $max | Only count up to this many backlinks, or INF for no max |
Definition at line 368 of file BacklinkCache.php.
BacklinkCache::getPage | ( | ) |
|
protected |
Get the field name prefix for a given table.
string | $table |
MWException |
Definition at line 273 of file BacklinkCache.php.
BacklinkCache::hasLinks | ( | $table | ) |
Check if there are any backlinks.
string | $table |
Definition at line 358 of file BacklinkCache.php.
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.
string | $table | The links table name |
int | $batchSize |
Definition at line 428 of file BacklinkCache.php.
|
protected |
Partition a DB result with backlinks in it into batches.
IResultWrapper | $res | Database result |
int | $batchSize | |
bool | $isComplete | Whether $res includes all the backlinks |
MWException |
Definition at line 517 of file BacklinkCache.php.
References $res.
|
protected |
Get the backlinks for a given table.
Cached in process memory only.
string | $table | |
int | bool | $startId | |
int | bool | $endId | |
int | $max | |
string | $select | 'all' or 'ids' |
Definition at line 211 of file BacklinkCache.php.
BacklinkCache::setDB | ( | $db | ) |
Set the Database object to use.
IDatabase | $db |
Definition at line 151 of file BacklinkCache.php.
|
protected |
Local copy of a database object.
Accessor: BacklinkCache::getDB() Mutator : BacklinkCache::setDB() Cleared with BacklinkCache::clear()
Definition at line 91 of file BacklinkCache.php.
|
protected |
Contains the whole links from a database result.
This is raw data that will be partitioned in $partitionCache
Initialized with BacklinkCache::getLinks() Cleared with BacklinkCache::clear()
Definition at line 79 of file BacklinkCache.php.
|
staticprotected |
Definition at line 55 of file BacklinkCache.php.
|
protected |
Local copy of a PageReference object.
Definition at line 97 of file BacklinkCache.php.
|
protected |
Multi dimensions array representing batches.
Keys are:
(string) links table name (int) batch size 'numRows' : Number of rows for this link table 'batches' : [ $start, $end ]
Cleared with BacklinkCache::clear()
Definition at line 69 of file BacklinkCache.php.
|
protected |
Definition at line 82 of file BacklinkCache.php.