<?php
/**
* Cache for article titles (prefixed DB keys) and ids linked from one source
- * @package MediaWiki
- * @subpackage Cache
- */
-
-/**
- * @package MediaWiki
- * @subpackage Cache
+ *
+ * @addtogroup Cache
*/
class LinkCache {
// Increment $mClassVer whenever old serialized versions of this class
/**
* Get an instance of this class
*/
- function &singleton() {
+ static function &singleton() {
static $instance;
if ( !isset( $instance ) ) {
$instance = new LinkCache;
return $instance;
}
- function LinkCache() {
+ function __construct() {
$this->mForUpdate = false;
$this->mPageLinks = array();
$this->mGoodLinks = array();
}
/* private */ function getKey( $title ) {
- global $wgDBname;
- return $wgDBname.':lc:title:'.$title;
+ return wfMemcKey( 'lc', 'title', $title );
}
/**
function getPageLinks() { return $this->mPageLinks; }
function getGoodLinks() { return $this->mGoodLinks; }
function getBadLinks() { return array_keys( $this->mBadLinks ); }
-
+
/**
* Add a title to the link cache, return the page_id or zero if non-existent
- * @param string $title Title to add
+ * @param $title String: title to add
* @return integer
*/
function addLink( $title ) {
return 0;
}
}
-
+
/**
* Add a title to the link cache, return the page_id or zero if non-existent
- * @param Title $nt Title to add
+ * @param $nt Title to add.
* @return integer
*/
function addLinkObj( &$nt ) {
$id = $wgMemc->get( $key = $this->getKey( $title ) );
if( ! is_integer( $id ) ) {
if ( $this->mForUpdate ) {
- $db =& wfGetDB( DB_MASTER );
+ $db = wfGetDB( DB_MASTER );
if ( !( $wgAntiLockFlags & ALF_NO_LINK_LOCK ) ) {
$options = array( 'FOR UPDATE' );
} else {
$options = array();
}
} else {
- $db =& wfGetDB( DB_SLAVE );
+ $db = wfGetDB( DB_SLAVE );
$options = array();
}
$this->mBadLinks = array();
}
}
-?>
+