MediaWiki fundraising/REL1_35
|
Class for fetching backlink lists, approximate backlink counts and partitions. More...
Public Member Functions | |
__construct (Title $title) | |
Create a new BacklinkCache. | |
__sleep () | |
Serialization handler, diasallows to serialize the database to prevent failures after this class is deserialized from cache with dead DB connection. | |
clear () | |
Clear locally stored data and database object. | |
getCascadeProtectedLinks () | |
Get a Title iterator for cascade-protected template/file use backlinks. | |
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. | |
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 (Title $title) |
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. | |
array[] | $partitionCache = [] |
Multi dimensions array representing batches. | |
$title | |
Local copy of a Title object. | |
WANObjectCache | $wanCache |
Static Protected Attributes | |
static BacklinkCache | $instance |
Private Member Functions | |
makeCheckKey () | |
Returns check key for the backlinks cache for a particular title. | |
Private Attributes | |
const | CACHE_EXPIRY = 3600 |
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 $title->getBacklinkCache().
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 47 of file BacklinkCache.php.
BacklinkCache::__construct | ( | Title | $title | ) |
BacklinkCache::__sleep | ( | ) |
Serialization handler, diasallows to serialize the database to prevent failures after this class is deserialized from cache with dead DB connection.
Definition at line 130 of file BacklinkCache.php.
BacklinkCache::clear | ( | ) |
Clear locally stored data and database object.
Invalidate data in memcache.
Definition at line 137 of file BacklinkCache.php.
References makeCheckKey().
|
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.
Definition at line 116 of file BacklinkCache.php.
References $instance, and $title.
Referenced by Title\getBacklinkCache().
BacklinkCache::getCascadeProtectedLinks | ( | ) |
Get a Title iterator for cascade-protected template/file use backlinks.
Definition at line 524 of file BacklinkCache.php.
|
protected |
Get the SQL condition array for selecting backlinks, with a join on the page table.
string | $table |
MWException |
Definition at line 278 of file BacklinkCache.php.
References getDB(), getPrefix(), and LIST_OR.
Referenced by queryLinks().
|
protected |
Get the replica DB connection to the database When non existing, will initialize the connection.
Definition at line 158 of file BacklinkCache.php.
References $db, DB_REPLICA, and wfGetDB().
Referenced by getCascadeProtectedLinks(), getConditions(), and queryLinks().
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 | $max |
Definition at line 174 of file BacklinkCache.php.
References queryLinks().
Referenced by getNumLinks().
BacklinkCache::getNumLinks | ( | $table, | |
$max = INF ) |
Get the approximate number of backlinks.
string | $table | |
int | $max | Only count up to this many backlinks |
Definition at line 334 of file BacklinkCache.php.
References $wgUpdateRowsPerJob, getLinks(), makeCheckKey(), and partition().
Referenced by hasLinks().
|
protected |
Get the field name prefix for a given table.
string | $table |
MWException |
Definition at line 249 of file BacklinkCache.php.
Referenced by getConditions(), and queryLinks().
BacklinkCache::hasLinks | ( | $table | ) |
Check if there are any backlinks.
string | $table |
Definition at line 324 of file BacklinkCache.php.
References getNumLinks().
|
private |
Returns check key for the backlinks cache for a particular title.
Definition at line 574 of file BacklinkCache.php.
Referenced by clear(), getNumLinks(), and partition().
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 394 of file BacklinkCache.php.
References $res, makeCheckKey(), partitionResult(), queryLinks(), and wfDebug().
Referenced by getNumLinks().
|
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 483 of file BacklinkCache.php.
References $res.
Referenced by partition().
|
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 187 of file BacklinkCache.php.
References $res, getConditions(), getDB(), getPrefix(), and wfDebug().
Referenced by getLinks(), and partition().
BacklinkCache::setDB | ( | $db | ) |
Set the Database object to use.
IDatabase | $db |
Definition at line 149 of file BacklinkCache.php.
References $db.
|
protected |
Local copy of a database object.
Accessor: BacklinkCache::getDB() Mutator : BacklinkCache::setDB() Cleared with BacklinkCache::clear()
Definition at line 89 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 75 of file BacklinkCache.php.
|
staticprotected |
Definition at line 51 of file BacklinkCache.php.
Referenced by get().
|
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 65 of file BacklinkCache.php.
|
protected |
Local copy of a Title object.
Definition at line 94 of file BacklinkCache.php.
Referenced by __construct(), and get().
|
protected |
Definition at line 80 of file BacklinkCache.php.
|
private |
Definition at line 96 of file BacklinkCache.php.