93 if ( !isset( self::$instances[$id] ) ) {
94 self::$instances[$id] = self::newFromId( $id );
97 return self::$instances[$id];
108 if ( !isset( self::$wanInstances[$id] ) ) {
109 self::$wanInstances[$id] = self::newWANCacheFromId( $id );
112 return self::$wanInstances[$id];
129 } elseif ( $id ===
'hash' ) {
133 throw new InvalidArgumentException(
"Invalid object cache type \"$id\" requested. " .
134 "It is not present in \$wgObjectCaches." );
153 if ( is_string( $keyspace ) && $keyspace !==
'' ) {
172 if ( isset(
$params[
'loggroup'] ) ) {
173 $params[
'logger'] = LoggerFactory::getInstance(
$params[
'loggroup'] );
175 $params[
'logger'] = LoggerFactory::getInstance(
'objectcache' );
177 if ( !isset(
$params[
'keyspace'] ) ) {
178 $params[
'keyspace'] = self::getDefaultKeyspace();
180 if ( isset(
$params[
'factory'] ) ) {
182 } elseif ( isset(
$params[
'class'] ) ) {
187 :
'DeferredUpdates::addCallableUpdate';
193 if ( is_a( $class, SqlBagOStuff::class,
true ) ) {
194 if ( isset(
$params[
'server'] ) && !isset(
$params[
'servers'] ) ) {
199 if ( isset(
$params[
'servers'] ) ) {
200 foreach (
$params[
'servers'] as &$server ) {
201 if ( $server[
'type'] ===
'sqlite' && !isset( $server[
'dbDirectory'] ) ) {
202 $server[
'dbDirectory'] = MediaWikiServices::getInstance()
203 ->getMainConfig()->get(
'SQLiteDataDir' );
210 if ( is_subclass_of( $class, MemcachedBagOStuff::class ) ) {
211 if ( !isset(
$params[
'servers'] ) ) {
214 if ( !isset(
$params[
'debug'] ) ) {
217 if ( !isset(
$params[
'persistent'] ) ) {
220 if ( !isset(
$params[
'timeout'] ) ) {
226 throw new InvalidArgumentException(
"The definition of cache type \""
227 . print_r(
$params,
true ) .
"\" lacks both "
228 .
"factory and class parameters." );
248 foreach ( $candidates as $candidate ) {
251 $cache = self::getInstance( $candidate );
260 if ( MediaWikiServices::getInstance()->isServiceDisabled(
'DBLoadBalancer' ) ) {
268 return self::getInstance( $candidate );
289 $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
312 throw new UnexpectedValueException(
313 "Cache type \"$id\" requested is not present in \$wgWANObjectCaches." );
318 throw new UnexpectedValueException(
319 "Cache type \"{$params['cacheId']}\" is not present in \$wgObjectCaches." );
323 return self::newWANCacheFromParams(
$params );
335 $erGroup = MediaWikiServices::getInstance()->getEventRelayerGroup();
336 foreach (
$params[
'channels'] as $action => $channel ) {
337 $params[
'relayers'][$action] = $erGroup->getRelayer( $channel );
338 $params[
'channels'][$action] = $channel;
341 if ( isset(
$params[
'loggroup'] ) ) {
342 $params[
'logger'] = LoggerFactory::getInstance(
$params[
'loggroup'] );
344 $params[
'logger'] = LoggerFactory::getInstance(
'objectcache' );
371 return MediaWikiServices::getInstance()->getMainWANObjectCache();
394 return MediaWikiServices::getInstance()->getMainObjectStash();
401 self::$instances = [];
402 self::$wanInstances = [];
$GLOBALS['wgAutoloadClasses']['LocalisationUpdate']
$wgObjectCaches
Advanced object cache configuration.
$wgParserCacheType
The cache type for storing article HTML.
$wgCachePrefix
Overwrite the caching key prefix with custom value.
$wgMessageCacheType
The cache type for storing the contents of the MediaWiki namespace.
$wgWANObjectCaches
Advanced WAN object cache configuration.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
interface is intended to be more or less compatible with the PHP memcached client.
A BagOStuff object with no objects in it.
Simple store for keeping values in an associative array for the current process.
Functions to get cache objects.
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)
static getMainWANInstance()
Get the main WAN cache object.
static getMainStashInstance()
Get the cache object for the main stash.
static newFromId( $id)
Create a new cache object of the specified type.
static newAnything( $params)
Factory function for CACHE_ANYTHING (referenced from DefaultSettings.php)
static getDefaultKeyspace()
Get the default keyspace for this wiki.
static clear()
Clear all the cached instances.
static newWANCacheFromId( $id)
Create a new cache object of the specified type.
static BagOStuff[] $instances
Map of (id => BagOStuff)
static newWANCacheFromParams(array $params)
Create a new cache object of the specified type.
static WANObjectCache[] $wanInstances
Map of (id => WANObjectCache)
static getInstance( $id)
Get a cached instance of the specified type of cache object.
static newFromParams( $params)
Create a new cache object from parameters.
static getLocalClusterInstance()
Get the main cluster-local cache object.
Multi-datacenter aware caching interface.
CACHE_MEMCACHED $wgMainCacheType