Go to the documentation of this file.
79 if ( !isset( self::$instances[$id] ) ) {
83 return self::$instances[$id];
100 } elseif ( $id ===
'hash' ) {
104 throw new InvalidArgumentException(
"Invalid object cache type \"$id\" requested. " .
105 "It is not present in \$wgObjectCaches." );
124 if ( is_string( $keyspace ) && $keyspace !==
'' ) {
146 'logger' => LoggerFactory::getInstance( $params[
'loggroup'] ??
'objectcache' ),
148 'asyncHandler' => [ DeferredUpdates::class,
'addCallableUpdate' ],
149 'reportDupes' =>
true,
152 if ( !isset( $params[
'stats'] ) ) {
153 $params[
'stats'] = MediaWikiServices::getInstance()->getStatsdDataFactory();
156 if ( isset( $params[
'factory'] ) ) {
157 return call_user_func( $params[
'factory'], $params );
160 if ( !isset( $params[
'class'] ) ) {
161 throw new InvalidArgumentException(
162 'No "factory" nor "class" provided; got "' . print_r( $params,
true ) .
'"'
166 $class = $params[
'class'];
167 $conf = $conf ?? MediaWikiServices::getInstance()->getMainConfig();
170 if ( is_a( $class, SqlBagOStuff::class,
true ) ) {
171 if ( isset( $params[
'server'] ) && !isset( $params[
'servers'] ) ) {
172 $params[
'servers'] = [ $params[
'server'] ];
173 unset( $params[
'server'] );
176 if ( isset( $params[
'servers'] ) ) {
177 foreach ( $params[
'servers'] as &$server ) {
178 if ( $server[
'type'] ===
'sqlite' && !isset( $server[
'dbDirectory'] ) ) {
179 $server[
'dbDirectory'] = $conf->get(
'SQLiteDataDir' );
182 } elseif ( !isset( $params[
'localKeyLB'] ) ) {
183 $params[
'localKeyLB'] = [
184 'factory' =>
function () {
185 return MediaWikiServices::getInstance()->getDBLoadBalancer();
192 if ( is_subclass_of( $class, MemcachedBagOStuff::class ) ) {
194 'servers' => $conf->get(
'MemCachedServers' ),
195 'persistent' => $conf->get(
'MemCachedPersistent' ),
196 'timeout' => $conf->get(
'MemCachedTimeout' ),
200 return new $class( $params );
219 foreach ( $candidates as $candidate ) {
230 if ( MediaWikiServices::getInstance()->isServiceDisabled(
'DBLoadBalancer' ) ) {
259 $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
286 self::$instances = [];
305 'reportDupes' =>
false,
309 if ( function_exists(
'apcu_fetch' ) ) {
311 if ( PHP_SAPI !==
'cli' || ini_get(
'apc.enable_cli' ) ) {
314 } elseif ( function_exists(
'wincache_ucache_get' ) ) {
332 if ( function_exists(
'apcu_fetch' ) ) {
334 if ( PHP_SAPI !==
'cli' || ini_get(
'apc.enable_cli' ) ) {
337 } elseif ( function_exists(
'wincache_ucache_get' ) ) {
static clear()
Clear all the cached instances.
static newFromId( $id)
Create a new cache object of the specified type.
Functions to get cache objects.
static getCurrentWikiDbDomain()
static getLocalClusterInstance()
Get the main cluster-local cache object.
Simple store for keeping values in an associative array for the current process.
A BagOStuff object with no objects in it.
static makeLocalServerCache()
Create a new BagOStuff instance for local-server caching.
static detectLocalServerCache()
Detects which local server cache library is present and returns a configuration for it.
static BagOStuff[] $instances
Map of (id => BagOStuff)
$wgMessageCacheType
The cache type for storing the contents of the MediaWiki namespace.
Class representing a cache/ephemeral data store.
static newAnything( $params)
Factory function for CACHE_ANYTHING (referenced from DefaultSettings.php)
Interface for configuration instances.
static newFromParams(array $params, Config $conf=null)
Create a new cache object from parameters.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
$wgMainCacheType
Main cache type.
$wgCachePrefix
Overwrite the caching key prefix with custom value.
$wgObjectCaches
Advanced object cache configuration.
static getInstance( $id)
Get a cached instance of the specified type of cache object.
$wgParserCacheType
The cache type for storing article HTML.
This is a wrapper for APCU's shared memory functions.
static getDefaultKeyspace()
Get the default keyspace for this wiki.
Wrapper for WinCache object caching functions; identical interface to the APC wrapper.
static getLocalServerInstance( $fallback=CACHE_NONE)
Factory function for CACHE_ACCEL (referenced from DefaultSettings.php)