Use this to define the class names and constructor parameters which are used for the various cache types.
Custom cache types may be defined here and referenced from $wgMainCacheType, $wgMessageCacheType or $wgParserCacheType.
The format is an associative array where the key is a cache identifier, and the value is an associative array of parameters.
The "class" parameter is the class name which will be used.
Alternatively, a "factory" parameter may be given, giving a callable function which will generate a suitable cache object.
Custom cache types
You can also create other cache configurations in addition to the built in CACHE_ constants by adding them.
For example, to use redis as your cache (which does not have a built in CACHE_XXX constant) you can do:
$wgObjectCaches['redis']=['class'=>'RedisBagOStuff','servers'=>['127.0.0.1:6379'],'password'=>'Your-Redis-password',// Highly recommended, otherwise comment out this line.'persistent'=>true,];$wgMainCacheType='redis';
The MediaWiki-Vagrant appliance runs a redis service and with this configuration.
Default value
The 'slaveOnly' option for SqlBagOStuff <translate> (deprecated in <tvar name=2>1.34</tvar>)</translate>, was removed. Use 'replicaOnly' instead.
<td class="mw-version-versionbox" title="<translate nowrap> The latest stable version is <tvar name=1>1.41</tvar></translate>">
<translate> ≥</translate> 1.42
<translate> MediaWiki version:</translate>
$wgObjectCaches=[CACHE_NONE=>['class'=>EmptyBagOStuff::class,'reportDupes'=>false],CACHE_DB=>['class'=>SqlBagOStuff::class,'loggroup'=>'SQLBagOStuff'],'memcached-php'=>['class'=>MemcachedPhpBagOStuff::class,'loggroup'=>'memcached'],'memcached-pecl'=>['class'=>MemcachedPeclBagOStuff::class,'loggroup'=>'memcached'],'hash'=>['class'=>HashBagOStuff::class,'reportDupes'=>false],// Deprecated since 1.35.// - To configure a wg*CacheType variable to use the local server cache,// use CACHE_ACCEL instead, which will select these automatically.// - To access the object for the local server cache at run-time,// use MediaWikiServices::getLocalServerObjectCache()// instead of e.g. ObjectCache::getInstance( 'apcu' ).// - To instantiate a new one of these explicitly, do so directly// by using `new APCUBagOStuff( [ … ] )`// - To instantiate a new one of these including auto-detection and fallback,// use ObjectCache::makeLocalServerCache().'apc'=>['class'=>APCUBagOStuff::class,'reportDupes'=>false],'apcu'=>['class'=>APCUBagOStuff::class,'reportDupes'=>false],'wincache'=>['class'=>WinCacheBagOStuff::class,'reportDupes'=>false],];
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.41</tvar> is stable version</translate>">
1.38 – 1.41
<translate> MediaWiki versions:</translate>
$wgObjectCaches=[CACHE_NONE=>['class'=>EmptyBagOStuff::class,'reportDupes'=>false],CACHE_DB=>['class'=>SqlBagOStuff::class,'loggroup'=>'SQLBagOStuff'],CACHE_ANYTHING=>['factory'=>'ObjectCache::newAnything'],CACHE_ACCEL=>['factory'=>'ObjectCache::getLocalServerInstance'],'db-replicated'=>['class'=>ReplicatedBagOStuff::class,'readFactory'=>['factory'=>'ObjectCache::newFromParams','args'=>[['class'=>SqlBagOStuff::class,'replicaOnly'=>true]]],'writeFactory'=>['factory'=>'ObjectCache::newFromParams','args'=>[['class'=>SqlBagOStuff::class,'replicaOnly'=>false]]],'loggroup'=>'SQLBagOStuff','reportDupes'=>false],'memcached-php'=>['class'=>MemcachedPhpBagOStuff::class,'loggroup'=>'memcached'],'memcached-pecl'=>['class'=>MemcachedPeclBagOStuff::class,'loggroup'=>'memcached'],'hash'=>['class'=>HashBagOStuff::class,'reportDupes'=>false],// Deprecated since 1.35.// - To configure a wg*CacheType variable to use the local server cache,// use CACHE_ACCEL instead, which will select these automatically.// - To access the object for the local server cache at run-time,// use MediaWikiServices::getLocalServerObjectCache()// instead of e.g. ObjectCache::getInstance( 'apcu' ).// - To instantiate a new one of these explicitly, do so directly// by using `new APCUBagOStuff( [ … ] )`// - To instantiate a new one of these including auto-detection and fallback,// use ObjectCache::makeLocalServerCache().'apc'=>['class'=>APCUBagOStuff::class,'reportDupes'=>false],'apcu'=>['class'=>APCUBagOStuff::class,'reportDupes'=>false],'wincache'=>['class'=>WinCacheBagOStuff::class,'reportDupes'=>false],];
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.37</tvar> is unsupported version</translate>">
1.35 – 1.37
<translate> MediaWiki versions:</translate>
$wgObjectCaches=[CACHE_NONE=>['class'=>EmptyBagOStuff::class,'reportDupes'=>false],CACHE_DB=>['class'=>SqlBagOStuff::class,'loggroup'=>'SQLBagOStuff'],CACHE_ANYTHING=>['factory'=>'ObjectCache::newAnything'],CACHE_ACCEL=>['factory'=>'ObjectCache::getLocalServerInstance'],CACHE_MEMCACHED=>['class'=>MemcachedPhpBagOStuff::class,'loggroup'=>'memcached'],'db-replicated'=>['class'=>ReplicatedBagOStuff::class,'readFactory'=>['factory'=>'ObjectCache::newFromParams','args'=>[['class'=>SqlBagOStuff::class,'replicaOnly'=>true]]],'writeFactory'=>['factory'=>'ObjectCache::newFromParams','args'=>[['class'=>SqlBagOStuff::class,'replicaOnly'=>false]]],'loggroup'=>'SQLBagOStuff','reportDupes'=>false],'memcached-php'=>['class'=>MemcachedPhpBagOStuff::class,'loggroup'=>'memcached'],'memcached-pecl'=>['class'=>MemcachedPeclBagOStuff::class,'loggroup'=>'memcached'],'hash'=>['class'=>HashBagOStuff::class,'reportDupes'=>false],// Deprecated since 1.35.// - To configure a wg*CacheType variable to use the local server cache,// use CACHE_ACCEL instead, which will select these automatically.// - To access the object for the local server cache at run-time,// use MediaWikiServices::getLocalServerObjectCache()// instead of e.g. ObjectCache::getInstance( 'apcu' ).// - To instantiate a new one of these explicitly, do so directly// by using `new APCUBagOStuff( [ … ] )`// - To instantiate a new one of these including auto-detection and fallback,// use ObjectCache::makeLocalServerCache().'apc'=>['class'=>APCUBagOStuff::class,'reportDupes'=>false],'apcu'=>['class'=>APCUBagOStuff::class,'reportDupes'=>false],'wincache'=>['class'=>WinCacheBagOStuff::class,'reportDupes'=>false],];
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.34</tvar> is unsupported version</translate>">