Clean up the variable names while at it.
Change-Id: I3b7860c0657111d73567e247bcc1ebcbaef53e22
* @ingroup Cache
*/
class LinkCache {
* @ingroup Cache
*/
class LinkCache {
- /** @var HashBagOStuff */
- private $mGoodLinks;
- /** @var HashBagOStuff */
- private $mBadLinks;
+ /** @var MapCacheLRU */
+ private $goodLinks;
+ /** @var MapCacheLRU */
+ private $badLinks;
/** @var WANObjectCache */
private $wanCache;
/** @var WANObjectCache */
private $wanCache;
const MAX_SIZE = 10000;
public function __construct( TitleFormatter $titleFormatter, WANObjectCache $cache ) {
const MAX_SIZE = 10000;
public function __construct( TitleFormatter $titleFormatter, WANObjectCache $cache ) {
- $this->mGoodLinks = new HashBagOStuff( [ 'maxKeys' => self::MAX_SIZE ] );
- $this->mBadLinks = new HashBagOStuff( [ 'maxKeys' => self::MAX_SIZE ] );
+ $this->goodLinks = new MapCacheLRU( self::MAX_SIZE );
+ $this->badLinks = new MapCacheLRU( self::MAX_SIZE );
$this->wanCache = $cache;
$this->titleFormatter = $titleFormatter;
}
$this->wanCache = $cache;
$this->titleFormatter = $titleFormatter;
}
* @return int Page ID or zero
*/
public function getGoodLinkID( $title ) {
* @return int Page ID or zero
*/
public function getGoodLinkID( $title ) {
- $info = $this->mGoodLinks->get( $title );
+ $info = $this->goodLinks->get( $title );
if ( !$info ) {
return 0;
}
if ( !$info ) {
return 0;
}
*/
public function getGoodLinkFieldObj( LinkTarget $target, $field ) {
$dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
*/
public function getGoodLinkFieldObj( LinkTarget $target, $field ) {
$dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
- $info = $this->mGoodLinks->get( $dbkey );
+ $info = $this->goodLinks->get( $dbkey );
if ( !$info ) {
return null;
}
if ( !$info ) {
return null;
}
*/
public function isBadLink( $title ) {
// Use get() to ensure it records as used for LRU.
*/
public function isBadLink( $title ) {
// Use get() to ensure it records as used for LRU.
- return $this->mBadLinks->get( $title ) !== false;
+ return $this->badLinks->has( $title );
$revision = 0, $model = null, $lang = null
) {
$dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
$revision = 0, $model = null, $lang = null
) {
$dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
- $this->mGoodLinks->set( $dbkey, [
+ $this->goodLinks->set( $dbkey, [
'id' => (int)$id,
'length' => (int)$len,
'redirect' => (int)$redir,
'id' => (int)$id,
'length' => (int)$len,
'redirect' => (int)$redir,
*/
public function addGoodLinkObjFromRow( LinkTarget $target, $row ) {
$dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
*/
public function addGoodLinkObjFromRow( LinkTarget $target, $row ) {
$dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
- $this->mGoodLinks->set( $dbkey, [
+ $this->goodLinks->set( $dbkey, [
'id' => intval( $row->page_id ),
'length' => intval( $row->page_len ),
'redirect' => intval( $row->page_is_redirect ),
'id' => intval( $row->page_id ),
'length' => intval( $row->page_len ),
'redirect' => intval( $row->page_is_redirect ),
public function addBadLinkObj( LinkTarget $target ) {
$dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
if ( !$this->isBadLink( $dbkey ) ) {
public function addBadLinkObj( LinkTarget $target ) {
$dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
if ( !$this->isBadLink( $dbkey ) ) {
- $this->mBadLinks->set( $dbkey, 1 );
+ $this->badLinks->set( $dbkey, 1 );
* @param string $title Prefixed DB key
*/
public function clearBadLink( $title ) {
* @param string $title Prefixed DB key
*/
public function clearBadLink( $title ) {
- $this->mBadLinks->delete( $title );
+ $this->badLinks->clear( $title );
*/
public function clearLink( LinkTarget $target ) {
$dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
*/
public function clearLink( LinkTarget $target ) {
$dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
- $this->mBadLinks->delete( $dbkey );
- $this->mGoodLinks->delete( $dbkey );
+ $this->badLinks->clear( $dbkey );
+ $this->goodLinks->clear( $dbkey );
* Clears cache
*/
public function clear() {
* Clears cache
*/
public function clear() {
- $this->mGoodLinks->clear();
- $this->mBadLinks->clear();
+ $this->goodLinks->clear();
+ $this->badLinks->clear();