MediaWiki  REL1_19
BacklinkCache Class Reference

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

List of all members.

Public Member Functions

 __construct ($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)
 Get the backlinks for a given table.
 getNumLinks ($table)
 Get the approximate number of backlinks.
 partition ($table, $batchSize)
 Partition the backlinks into batches.
 setDB ($db)
 Set the Database object to use.

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)
 Partition a DB result with backlinks in it into batches.

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.

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 $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 27 of file BacklinkCache.php.


Constructor & Destructor Documentation

Create a new BacklinkCache.

Parameters:
Title$title: Title object to create a backlink cache for.

Definition at line 70 of file BacklinkCache.php.

References $title.


Member Function Documentation

Serialization handler, diasallows to serialize the database to prevent failures after this class is deserialized from cache with dead DB connection.

Returns:
array

Definition at line 81 of file BacklinkCache.php.

Clear locally stored data and database object.

Definition at line 88 of file BacklinkCache.php.

BacklinkCache::getConditions ( table) [protected]

Get the SQL condition array for selecting backlinks, with a join on the page table.

Parameters:
$tableString

Definition at line 210 of file BacklinkCache.php.

References getPrefix(), and wfRunHooks().

Referenced by getLinks().

Here is the call graph for this function:

Here is the caller graph for this function:

BacklinkCache::getDB ( ) [protected]

Get the slave connection to the database When non existing, will initialize the connection.

Returns:
Database object

Definition at line 108 of file BacklinkCache.php.

References wfGetDB().

Referenced by getLinks().

Here is the call graph for this function:

Here is the caller graph for this function:

BacklinkCache::getLinks ( table,
startId = false,
endId = false 
)

Get the backlinks for a given table.

Cached in process memory only.

Parameters:
$tableString
$startIdInteger or false
$endIdInteger or false
Returns:
TitleArrayFromResult

Definition at line 123 of file BacklinkCache.php.

References $res, getConditions(), getDB(), getPrefix(), TitleArray\newFromResult(), wfDebug(), wfProfileIn(), and wfProfileOut().

Referenced by getNumLinks(), and partition().

Here is the call graph for this function:

Here is the caller graph for this function:

Get the approximate number of backlinks.

Parameters:
$tableString
Returns:
integer

Definition at line 262 of file BacklinkCache.php.

References getLinks().

Here is the call graph for this function:

BacklinkCache::getPrefix ( table) [protected]

Get the field name prefix for a given table.

Parameters:
$tableString

Definition at line 183 of file BacklinkCache.php.

References wfRunHooks().

Referenced by getConditions(), and getLinks().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
$tableString: the links table name
$batchSizeInteger
Returns:
Array

Definition at line 286 of file BacklinkCache.php.

References $wgMemc, getLinks(), partitionResult(), wfDebug(), and wfMemcKey().

Here is the call graph for this function:

BacklinkCache::partitionResult ( res,
batchSize 
) [protected]

Partition a DB result with backlinks in it into batches.

Parameters:
$resResultWrapper database result
$batchSizeinteger
Returns:
array
See also:

Definition at line 345 of file BacklinkCache.php.

References $res.

Referenced by partition().

Here is the caller graph for this function:

Set the Database object to use.

Parameters:
$dbDatabaseBase

Definition at line 99 of file BacklinkCache.php.

References $db.


Member Data Documentation

BacklinkCache::$db [protected]

Local copy of a database object.

Accessor: BacklinkCache::getDB() Mutator : BacklinkCache::setDB() Cleared with BacklinkCache::clear()

Definition at line 57 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 48 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 )

See also:
BacklinkCache::partitionResult()

Cleared with BacklinkCache::clear()

Definition at line 39 of file BacklinkCache.php.

BacklinkCache::$title [protected]

Local copy of a Title object.

Definition at line 62 of file BacklinkCache.php.

Referenced by __construct().

Definition at line 64 of file BacklinkCache.php.


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