94 if ( !isset( self::$instances[$id] ) ) {
95 self::$instances[$id] = self::newFromId( $id );
98 return self::$instances[$id];
109 if ( !isset( self::$wanInstances[$id] ) ) {
110 self::$wanInstances[$id] = self::newWANCacheFromId( $id );
113 return self::$wanInstances[$id];
126 if ( !isset( $wgObjectCaches[$id] ) ) {
127 throw new MWException(
"Invalid object cache type \"$id\" requested. " .
128 "It is not present in \$wgObjectCaches." );
131 return self::newFromParams( $wgObjectCaches[$id] );
147 if ( is_string( $keyspace ) && $keyspace !==
'' ) {
166 if ( isset(
$params[
'loggroup'] ) ) {
167 $params[
'logger'] = LoggerFactory::getInstance(
$params[
'loggroup'] );
169 $params[
'logger'] = LoggerFactory::getInstance(
'objectcache' );
171 if ( !isset(
$params[
'keyspace'] ) ) {
172 $params[
'keyspace'] = self::getDefaultKeyspace();
174 if ( isset(
$params[
'factory'] ) ) {
176 } elseif ( isset(
$params[
'class'] ) ) {
181 :
'DeferredUpdates::addCallableUpdate';
187 if ( is_subclass_of( $class,
'MemcachedBagOStuff' ) ) {
188 if ( !isset(
$params[
'servers'] ) ) {
191 if ( !isset(
$params[
'debug'] ) ) {
194 if ( !isset(
$params[
'persistent'] ) ) {
197 if ( !isset(
$params[
'timeout'] ) ) {
203 throw new MWException(
"The definition of cache type \""
204 . print_r(
$params,
true ) .
"\" lacks both "
205 .
"factory and class parameters." );
225 foreach ( $candidates
as $candidate ) {
227 return self::getInstance( $candidate );
233 MediaWikiServices::getInstance()->getDBLoadBalancer();
241 return self::getInstance( $candidate );
262 if ( function_exists(
'apc_fetch' ) ) {
264 } elseif ( function_exists(
'xcache_get' ) &&
wfIniGetBool(
'xcache.var_size' ) ) {
266 } elseif ( function_exists(
'wincache_ucache_get' ) ) {
276 return self::getInstance( $id );
289 } elseif ( !is_array(
$params ) ) {
294 return self::getLocalServerInstance(
$fallback );
308 if ( !isset( $wgWANObjectCaches[$id] ) ) {
309 throw new MWException(
"Invalid object cache type \"$id\" requested. " .
310 "It is not present in \$wgWANObjectCaches." );
313 $params = $wgWANObjectCaches[$id];
314 foreach (
$params[
'channels']
as $action => $channel ) {
315 $params[
'relayers'][$action] = MediaWikiServices::getInstance()->getEventRelayerGroup()
316 ->getRelayer( $channel );
317 $params[
'channels'][$action] = $channel;
320 if ( isset(
$params[
'loggroup'] ) ) {
321 $params[
'logger'] = LoggerFactory::getInstance(
$params[
'loggroup'] );
323 $params[
'logger'] = LoggerFactory::getInstance(
'objectcache' );
339 return self::getInstance( $wgMainCacheType );
351 return self::getWANInstance( $wgMainWANCache );
375 return self::getInstance( $wgMainStash );
382 self::$instances = [];
383 self::$wanInstances = [];
static getMainWANInstance()
Get the main WAN cache object.
$wgMainStash
Main object stash type.
static newWANCacheFromId($id)
Create a new cache object of the specified type.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
static getInstance($id)
Get a cached instance of the specified type of cache object.
static getLocalClusterInstance()
Get the main cluster-local cache object.
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
$wgMainWANCache
Main Wide-Area-Network cache type.
static getMainStashInstance()
Get the cache object for the main stash.
when a variable name is used in a it is silently declared as a new local masking the global
$wgWANObjectCaches
Advanced WAN object cache configuration.
static BagOStuff[] $instances
Map of (id => BagOStuff)
$wgParserCacheType
The cache type for storing article HTML.
static newFromParams($params)
Create a new cache object from parameters.
wfIniGetBool($setting)
Safety wrapper around ini_get() for boolean settings.
$wgMessageCacheType
The cache type for storing the contents of the MediaWiki namespace.
static newAccelerator($params=[], $fallback=null)
$wgCachePrefix
Overwrite the caching key prefix with custom value.
CACHE_MEMCACHED $wgMainCacheType
static getDefaultKeyspace()
Get the default keyspace for this wiki.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static WANObjectCache[] $wanInstances
Map of (id => WANObjectCache)
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
static newAnything($params)
Factory function for CACHE_ANYTHING (referenced from DefaultSettings.php)
static getWANInstance($id)
Get a cached instance of the specified type of WAN cache object.
static getLocalServerInstance($fallback=CACHE_NONE)
Factory function for CACHE_ACCEL (referenced from DefaultSettings.php)
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method.MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances.The"Spi"in MediaWiki\Logger\Spi stands for"service provider interface".An SPI is an API intended to be implemented or extended by a third party.This software design pattern is intended to enable framework extension and replaceable components.It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki.The service provider interface allows the backend logging library to be implemented in multiple ways.The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime.This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance.Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
$wgObjectCaches
Advanced object cache configuration.
static clear()
Clear all the cached instances.
static newFromId($id)
Create a new cache object of the specified type.
Functions to get cache objects.