MediaWiki
REL1_22
|
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. | |
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. | |
Public Attributes | |
const | CACHE_EXPIRY = 3600 |
Protected Member Functions | |
getConditions ($table) | |
Get the SQL condition array for selecting backlinks, with a join on the page table. | |
getDB () | |
Get the slave 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) | |
Get the backlinks for a given table. | |
Protected Attributes | |
$db | |
Local copy of a database object. | |
$fullResultCache = array() | |
Contains the whole links from a database result. | |
$partitionCache = array() | |
Multi dimensions array representing batches. | |
$title | |
Local copy of a Title object. | |
Static Protected Attributes | |
static | $cache |
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 44 of file BacklinkCache.php.
BacklinkCache::__construct | ( | Title $ | title | ) |
Create a new BacklinkCache.
Definition at line 90 of file BacklinkCache.php.
Serialization handler, diasallows to serialize the database to prevent failures after this class is deserialized from cache with dead DB connection.
Definition at line 120 of file BacklinkCache.php.
References array().
Clear locally stored data and database object.
Definition at line 127 of file BacklinkCache.php.
References array().
static BacklinkCache::get | ( | Title $ | title | ) | [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 102 of file BacklinkCache.php.
References $cache, and $title.
Referenced by Title\getBacklinkCache().
BacklinkCache::getConditions | ( | $ | table | ) | [protected] |
Get the SQL condition array for selecting backlinks, with a join on the page table.
$table | String |
MWException |
Definition at line 255 of file BacklinkCache.php.
References array(), getPrefix(), title, and wfRunHooks().
Referenced by queryLinks().
BacklinkCache::getDB | ( | ) | [protected] |
Get the slave connection to the database When non existing, will initialize the connection.
Definition at line 147 of file BacklinkCache.php.
References wfGetDB().
Referenced by queryLinks().
BacklinkCache::getLinks | ( | $ | table, |
$ | startId = false , |
||
$ | endId = false , |
||
$ | max = INF |
||
) |
Get the backlinks for a given table.
Cached in process memory only.
$table | String |
$startId | Integer|false |
$endId | Integer|false |
$max | Integer|INF |
Definition at line 162 of file BacklinkCache.php.
References TitleArray\newFromResult(), and queryLinks().
Referenced by getNumLinks().
BacklinkCache::getNumLinks | ( | $ | table, |
$ | max = INF |
||
) |
Get the approximate number of backlinks.
$table | String |
$max | integer|INF Only count up to this many backlinks |
Definition at line 318 of file BacklinkCache.php.
References $count, $wgMemc, getLinks(), global, title, and wfMemcKey().
Referenced by hasLinks().
BacklinkCache::getPrefix | ( | $ | table | ) | [protected] |
Get the field name prefix for a given table.
$table | String |
MWException |
Definition at line 226 of file BacklinkCache.php.
References array(), and wfRunHooks().
Referenced by getConditions(), and queryLinks().
BacklinkCache::hasLinks | ( | $ | table | ) |
Check if there are any backlinks.
$table | String |
Definition at line 308 of file BacklinkCache.php.
References getNumLinks().
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 |
$batchSize | Integer |
Definition at line 358 of file BacklinkCache.php.
References $res, $wgMemc, array(), global, list, partitionResult(), queryLinks(), title, wfDebug(), and wfMemcKey().
BacklinkCache::partitionResult | ( | $ | res, |
$ | batchSize, | ||
$ | isComplete = true |
||
) | [protected] |
Partition a DB result with backlinks in it into batches.
$res | ResultWrapper database result |
$batchSize | integer |
$isComplete | bool Whether $res includes all the backlinks |
MWException |
Definition at line 434 of file BacklinkCache.php.
Referenced by partition().
BacklinkCache::queryLinks | ( | $ | table, |
$ | startId, | ||
$ | endId, | ||
$ | max | ||
) | [protected] |
Get the backlinks for a given table.
Cached in process memory only.
$table | String |
$startId | Integer|false |
$endId | Integer|false |
$max | Integer|INF |
Definition at line 174 of file BacklinkCache.php.
References $options, $res, array(), getConditions(), getDB(), getPrefix(), wfDebug(), wfProfileIn(), and wfProfileOut().
Referenced by getLinks(), and partition().
BacklinkCache::setDB | ( | $ | db | ) |
Set the Database object to use.
$db | DatabaseBase |
Definition at line 138 of file BacklinkCache.php.
References $db.
BacklinkCache::$cache [static, protected] |
Definition at line 46 of file BacklinkCache.php.
BacklinkCache::$db [protected] |
Local copy of a database object.
Accessor: BacklinkCache::getDB() Mutator : BacklinkCache::setDB() Cleared with BacklinkCache::clear()
Definition at line 76 of file BacklinkCache.php.
Referenced by setDB().
BacklinkCache::$fullResultCache = array() [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 67 of file BacklinkCache.php.
BacklinkCache::$partitionCache = array() [protected] |
Multi dimensions array representing batches.
Keys are: > (string) links table name > 'numRows' : Number of rows for this link table > 'batches' : array( $start, $end )
Cleared with BacklinkCache::clear()
Definition at line 58 of file BacklinkCache.php.
BacklinkCache::$title [protected] |
Local copy of a Title object.
Definition at line 81 of file BacklinkCache.php.
Referenced by __construct(), and get().
const BacklinkCache::CACHE_EXPIRY = 3600 |
Definition at line 83 of file BacklinkCache.php.