Go to the documentation of this file.
55 $this->goodLinks =
new MapCacheLRU( self::MAX_SIZE );
56 $this->badLinks =
new MapCacheLRU( self::MAX_SIZE );
68 return MediaWikiServices::getInstance()->getLinkCache();
82 return wfSetVar( $this->mForUpdate, $update );
90 $info = $this->goodLinks->get(
$title );
105 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
106 $info = $this->goodLinks->get( $dbkey );
110 return $info[$field];
119 return $this->badLinks->has(
$title );
134 $revision = 0, $model =
null,
$lang =
null
136 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
137 $this->goodLinks->set( $dbkey, [
139 'length' => (
int)$len,
140 'redirect' => (
int)$redir,
141 'revision' => (
int)$revision,
142 'model' => $model ? (
string)$model :
null,
144 'restrictions' =>
null
156 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
157 $this->goodLinks->set( $dbkey, [
158 'id' => intval( $row->page_id ),
159 'length' => intval( $row->page_len ),
160 'redirect' => intval( $row->page_is_redirect ),
161 'revision' => intval( $row->page_latest ),
162 'model' => !empty( $row->page_content_model )
163 ? strval( $row->page_content_model )
165 'lang' => !empty( $row->page_lang )
166 ? strval( $row->page_lang )
168 'restrictions' => !empty( $row->page_restrictions )
169 ? strval( $row->page_restrictions )
178 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
180 $this->badLinks->set( $dbkey, 1 );
188 $this->badLinks->clear(
$title );
195 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
196 $this->badLinks->clear( $dbkey );
197 $this->goodLinks->clear( $dbkey );
217 $fields[] =
'page_content_model';
220 $fields[] =
'page_lang';
233 $key = $this->titleFormatter->getPrefixedDBkey( $nt );
249 if ( $this->mForUpdate ) {
254 $row =
$cache->getWithSetCallback(
257 function ( $curValue, &$ttl,
array &$setOpts )
use (
$cache, $nt ) {
259 $setOpts += Database::getCacheSetOptions(
$dbr );
262 $mtime = $row ?
wfTimestamp( TS_UNIX, $row->page_touched ) :
false;
263 $ttl =
$cache->adaptiveTTL( $mtime, $ttl );
274 $id = intval( $row->page_id );
291 return [
$cache->makeKey(
'page',
$t->getNamespace(), sha1(
$t->getDBkey() ) ) ];
298 $ns =
$title->getNamespace();
313 $fields[] =
'page_touched';
343 $this->goodLinks->clear();
344 $this->badLinks->clear();
Cache for article titles (prefixed DB keys) and ids linked from one source.
addGoodLinkObjFromRow(LinkTarget $target, $row)
Same as above with better interface.
if(!isset( $args[0])) $lang
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
fetchPageRow(IDatabase $db, LinkTarget $nt)
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getMutableCacheKeys(WANObjectCache $cache, LinkTarget $t)
getGoodLinkFieldObj(LinkTarget $target, $field)
Get a field of a title object from cache.
forUpdate( $update=null)
General accessor to get/set whether the master DB should be used.
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
static getSelectFields()
Fields that LinkCache needs to select.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
namespace and then decline to actually register it file or subcat img or subcat $title
TitleFormatter $titleFormatter
__construct(TitleFormatter $titleFormatter, WANObjectCache $cache)
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
addBadLinkObj(LinkTarget $target)
static isContent( $index)
Does this namespace contain content, for the purposes of calculating statistics, etc?
Handles a simple LRU key/value map with a maximum number of entries.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
const MAX_SIZE
How many Titles to store.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
static isSubject( $index)
Is the given namespace is a subject (non-talk) namespace?
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
isCacheable(LinkTarget $title)
Multi-datacenter aware caching interface.
invalidateTitle(LinkTarget $title)
Purge the link cache for a title.
static singleton()
Get an instance of this class.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
addLinkObj(LinkTarget $nt)
Add a title to the link cache, return the page_id or zero if non-existent.
addGoodLinkObj( $id, LinkTarget $target, $len=-1, $redir=null, $revision=0, $model=null, $lang=null)
Add a link for the title to the link cache.
clearLink(LinkTarget $target)