Руководство:$wgObjectCaches

This page is a translated version of the page Manual:$wgObjectCaches and the translation is 100% complete.
Кэш: $wgObjectCaches
Расширенная конфигурация кэша объектов.
Введено в версии:1.18.0 (r83140)
Удалено в версии:всё ещё используется
Допустимые значения:(массив)
Значение по умолчанию:см. ниже

Подробнее

Расширенная конфигурация кэша объектов.

Используйте эту опцию для определения имен классов и параметров конструкторов, которые используются для различных типов кэша. Пользовательские типы кэша могут быть определены здесь и ссылаться на $wgMainCacheType , $wgMessageCacheType или $wgParserCacheType .

Формат представляет собой ассоциативный массив, где ключ - идентификатор кэша, а значение - ассоциативный массив параметров. Параметр "class" - это имя класса, который будет использоваться. В качестве альтернативы можно указать параметр "factory", который дает вызываемую функцию, генерирующую подходящий объект кэша.

Пользовательские типы кэша

Вы также можете создавать другие конфигурации кэша в дополнение к встроенным константам CACHE_, добавляя их. Например, чтобы использовать redis в качестве кэша (который не имеет встроенной константы CACHE_XXX), вы можете сделать следующее:

$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';

На устройстве MediaWiki-Vagrant работает служба redis, и при такой конфигурации.

Значение по умолчанию

The 'slaveOnly' option for SqlBagOStuff (устарело в 1.34), was removed. Use 'replicaOnly' instead.

Версия MediaWiki:
1.43
$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 ],
];
Версия MediaWiki:
1.42
$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 ],
];
Версии MediaWiki:
1.38 – 1.41
$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 ],
];
Версии MediaWiki:
1.35 – 1.37
$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 ],
];
Версия MediaWiki:
1.34
$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' => [
			'class' => SqlBagOStuff::class,
			'args'  => [ [ 'replicaOnly' => true ] ]
		],
		'writeFactory' => [
			'class' => SqlBagOStuff::class,
			'args'  => [ [ 'replicaOnly' => false ] ]
		],
		'loggroup'  => 'SQLBagOStuff',
		'reportDupes' => false
	],

	'apc' => [ 'class' => APCBagOStuff::class, 'reportDupes' => false ],
	'apcu' => [ 'class' => APCUBagOStuff::class, 'reportDupes' => false ],
	'wincache' => [ 'class' => WinCacheBagOStuff::class, 'reportDupes' => false ],
	'memcached-php' => [ 'class' => MemcachedPhpBagOStuff::class, 'loggroup' => 'memcached' ],
	'memcached-pecl' => [ 'class' => MemcachedPeclBagOStuff::class, 'loggroup' => 'memcached' ],
	'hash' => [ 'class' => HashBagOStuff::class, 'reportDupes' => false ],
];
Версии MediaWiki:
1.31 – 1.33
$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' => [
			'class' => SqlBagOStuff::class,
			'args'  => [ [ 'slaveOnly' => true ] ]
		],
		'writeFactory' => [
			'class' => SqlBagOStuff::class,
			'args'  => [ [ 'slaveOnly' => false ] ]
		],
		'loggroup'  => 'SQLBagOStuff',
		'reportDupes' => false
	],

	'apc' => [ 'class' => APCBagOStuff::class, 'reportDupes' => false ],
	'apcu' => [ 'class' => APCUBagOStuff::class, 'reportDupes' => false ],
	'wincache' => [ 'class' => WinCacheBagOStuff::class, 'reportDupes' => false ],
	'memcached-php' => [ 'class' => MemcachedPhpBagOStuff::class, 'loggroup' => 'memcached' ],
	'memcached-pecl' => [ 'class' => MemcachedPeclBagOStuff::class, 'loggroup' => 'memcached' ],
	'hash' => [ 'class' => HashBagOStuff::class, 'reportDupes' => false ],
];
Версии MediaWiki:
1.28 – 1.30
$wgObjectCaches = [
	CACHE_NONE => [ 'class' => 'EmptyBagOStuff', 'reportDupes' => false ],
	CACHE_DB => [ 'class' => 'SqlBagOStuff', 'loggroup' => 'SQLBagOStuff' ],

	CACHE_ANYTHING => [ 'factory' => 'ObjectCache::newAnything' ],
	CACHE_ACCEL => [ 'factory' => 'ObjectCache::getLocalServerInstance' ],
	CACHE_MEMCACHED => [ 'class' => 'MemcachedPhpBagOStuff', 'loggroup' => 'memcached' ],

	'db-replicated' => [
		'class'       => 'ReplicatedBagOStuff',
		'readFactory' => [
			'class' => 'SqlBagOStuff',
			'args'  => [ [ 'slaveOnly' => true ] ]
		],
		'writeFactory' => [
			'class' => 'SqlBagOStuff',
			'args'  => [ [ 'slaveOnly' => false ] ]
		],
		'loggroup'  => 'SQLBagOStuff',
		'reportDupes' => false
	],

	'apc' => [ 'class' => 'APCBagOStuff', 'reportDupes' => false ],
	'apcu' => [ 'class' => 'APCUBagOStuff', 'reportDupes' => false ],
	'xcache' => [ 'class' => 'XCacheBagOStuff', 'reportDupes' => false ],
	'wincache' => [ 'class' => 'WinCacheBagOStuff', 'reportDupes' => false ],
	'memcached-php' => [ 'class' => 'MemcachedPhpBagOStuff', 'loggroup' => 'memcached' ],
	'memcached-pecl' => [ 'class' => 'MemcachedPeclBagOStuff', 'loggroup' => 'memcached' ],
	'hash' => [ 'class' => 'HashBagOStuff', 'reportDupes' => false ],
];
Версия MediaWiki:
1.27
$wgObjectCaches = [
	CACHE_NONE => [ 'class' => 'EmptyBagOStuff', 'reportDupes' => false ],
	CACHE_DB => [ 'class' => 'SqlBagOStuff', 'loggroup' => 'SQLBagOStuff' ],

	CACHE_ANYTHING => [ 'factory' => 'ObjectCache::newAnything' ],
	CACHE_ACCEL => [ 'factory' => 'ObjectCache::getLocalServerInstance' ],
	CACHE_MEMCACHED => [ 'class' => 'MemcachedPhpBagOStuff', 'loggroup' => 'memcached' ],

	'db-replicated' => [
		'class'       => 'ReplicatedBagOStuff',
		'readFactory' => [
			'class' => 'SqlBagOStuff',
			'args'  => [ [ 'slaveOnly' => true ] ]
		],
		'writeFactory' => [
			'class' => 'SqlBagOStuff',
			'args'  => [ [ 'slaveOnly' => false ] ]
		],
		'loggroup'  => 'SQLBagOStuff'
	],

	'apc' => [ 'class' => 'APCBagOStuff', 'reportDupes' => false ],
	'apcu' => [ 'class' => 'APCUBagOStuff', 'reportDupes' => false ],
	'xcache' => [ 'class' => 'XCacheBagOStuff', 'reportDupes' => false ],
	'wincache' => [ 'class' => 'WinCacheBagOStuff', 'reportDupes' => false ],
	'memcached-php' => [ 'class' => 'MemcachedPhpBagOStuff', 'loggroup' => 'memcached' ],
	'memcached-pecl' => [ 'class' => 'MemcachedPeclBagOStuff', 'loggroup' => 'memcached' ],
	'hash' => [ 'class' => 'HashBagOStuff', 'reportDupes' => false ],
];
Версия MediaWiki:
1.26
$wgObjectCaches = array(
	CACHE_NONE => array( 'class' => 'EmptyBagOStuff' ),
	CACHE_DB => array( 'class' => 'SqlBagOStuff', 'loggroup' => 'SQLBagOStuff' ),

	CACHE_ANYTHING => array( 'factory' => 'ObjectCache::newAnything' ),
	CACHE_ACCEL => array( 'factory' => 'ObjectCache::newAccelerator' ),
	CACHE_MEMCACHED => array( 'factory' => 'ObjectCache::newMemcached', 'loggroup' => 'memcached' ),

	'db-replicated' => array(
		'class'       => 'ReplicatedBagOStuff',
		'readFactory' => array(
			'class' => 'SqlBagOStuff',
			'args'  => array( array( 'slaveOnly' => true ) )
		),
		'writeFactory' => array(
			'class' => 'SqlBagOStuff',
			'args'  => array( array( 'slaveOnly' => false ) )
		),
		'loggroup'  => 'SQLBagOStuff'
	),

	'apc' => array( 'class' => 'APCBagOStuff' ),
	'xcache' => array( 'class' => 'XCacheBagOStuff' ),
	'wincache' => array( 'class' => 'WinCacheBagOStuff' ),
	'memcached-php' => array( 'class' => 'MemcachedPhpBagOStuff', 'loggroup' => 'memcached' ),
	'memcached-pecl' => array( 'class' => 'MemcachedPeclBagOStuff', 'loggroup' => 'memcached' ),
	'hash' => array( 'class' => 'HashBagOStuff' ),
);
Версии MediaWiki:
1.23 – 1.25
$wgObjectCaches = array(
   CACHE_NONE => array( 'class' => 'EmptyBagOStuff' ),
   CACHE_DB => array( 'class' => 'SqlBagOStuff', 'table' => 'objectcache' ),
 
   CACHE_ANYTHING => array( 'factory' => 'ObjectCache::newAnything' ),
   CACHE_ACCEL => array( 'factory' => 'ObjectCache::newAccelerator' ),
   CACHE_MEMCACHED => array( 'factory' => 'ObjectCache::newMemcached' ),
 
   'apc' => array( 'class' => 'APCBagOStuff' ),
   'xcache' => array( 'class' => 'XCacheBagOStuff' ),
   'wincache' => array( 'class' => 'WinCacheBagOStuff' ),
   'memcached-php' => array( 'class' => 'MemcachedPhpBagOStuff' ),
   'memcached-pecl' => array( 'class' => 'MemcachedPeclBagOStuff' ),
   'hash' => array( 'class' => 'HashBagOStuff' ),
);
Версии MediaWiki:
1.20 – 1.22
$wgObjectCaches = array(
   CACHE_NONE => array( 'class' => 'EmptyBagOStuff' ),
   CACHE_DB => array( 'class' => 'SqlBagOStuff', 'table' => 'objectcache' ),
   CACHE_DBA => array( 'class' => 'DBABagOStuff' ),
 
   CACHE_ANYTHING => array( 'factory' => 'ObjectCache::newAnything' ),
   CACHE_ACCEL => array( 'factory' => 'ObjectCache::newAccelerator' ),
   CACHE_MEMCACHED => array( 'factory' => 'ObjectCache::newMemcached' ),
 
   'apc' => array( 'class' => 'APCBagOStuff' ),
   'xcache' => array( 'class' => 'XCacheBagOStuff' ),
   'wincache' => array( 'class' => 'WinCacheBagOStuff' ),
   'memcached-php' => array( 'class' => 'MemcachedPhpBagOStuff' ),
   'memcached-pecl' => array( 'class' => 'MemcachedPeclBagOStuff' ),
   'hash' => array( 'class' => 'HashBagOStuff' ),
);
Версия MediaWiki:
1.19
$wgObjectCaches = array(
   CACHE_NONE => array( 'class' => 'EmptyBagOStuff' ),
   CACHE_DB => array( 'class' => 'SqlBagOStuff', 'table' => 'objectcache' ),
   CACHE_DBA => array( 'class' => 'DBABagOStuff' ),
 
   CACHE_ANYTHING => array( 'factory' => 'ObjectCache::newAnything' ),
   CACHE_ACCEL => array( 'factory' => 'ObjectCache::newAccelerator' ),
   CACHE_MEMCACHED => array( 'factory' => 'ObjectCache::newMemcached' ),
 
   'apc' => array( 'class' => 'APCBagOStuff' ),
   'xcache' => array( 'class' => 'XCacheBagOStuff' ),
   'wincache' => array( 'class' => 'WinCacheBagOStuff' ),
   'memcached-php' => array( 'class' => 'MemcachedPhpBagOStuff' ),
   'hash' => array( 'class' => 'HashBagOStuff' ),
);
Версия MediaWiki:
1.18
$wgObjectCaches = array(
   CACHE_NONE => array( 'class' => 'EmptyBagOStuff' ),
   CACHE_DB => array( 'class' => 'SqlBagOStuff', 'table' => 'objectcache' ),
   CACHE_DBA => array( 'class' => 'DBABagOStuff' ),

   CACHE_ANYTHING => array( 'factory' => 'ObjectCache::newAnything' ),
   CACHE_ACCEL => array( 'factory' => 'ObjectCache::newAccelerator' ),
   CACHE_MEMCACHED => array( 'factory' => 'ObjectCache::newMemcached' ),

   'eaccelerator' => array( 'class' => 'eAccelBagOStuff' ),
   'apc' => array( 'class' => 'APCBagOStuff' ),
   'xcache' => array( 'class' => 'XCacheBagOStuff' ),
   'wincache' => array( 'class' => 'WinCacheBagOStuff' ),
   'memcached-php' => array( 'class' => 'MemcachedPhpBagOStuff' ),
   'hash' => array( 'class' => 'HashBagOStuff' ),
);