Jump to content

Handbuch:$wgMainCacheType

From mediawiki.org
This page is a translated version of the page Manual:$wgMainCacheType and the translation is 18% complete.
Zwischenspeicher: $wgMainCacheType
Objektcache-Einstellung
Eingeführt in Version:1.5.0
Entfernt in Version:Weiterhin vorhanden
Erlaubte Werte:(One of the CACHE constants (see below), or a string indicating the cache type set as key in $wgObjectCaches )
Standardwert:CACHE_NONE

Details

Allows to configure the object cache used.

Here are the keys available by default (defined as constants in Defines.php):

  • CACHE_NONEDo not cache (default).
  • CACHE_ANYTHINGUse $wgMessageCacheType or $wgParserCacheType if they are set to something other than CACHE_NONE or CACHE_ANYTHING. Otherwise use CACHE_DB.
  • CACHE_ACCELUse APCu if available. (maintenance/install.php will add the line $wgMainCacheType = CACHE_ACCEL; to your config.)
  • CACHE_MEMCACHEDUse memcached if available. Servers must additionally be specified in $wgMemCachedServers .
  • CACHE_DBUse the database table objectcache .
Warnung: This could potentially be slower than no caching, i.e. CACHE_NONE.

PHP works by compiling a PHP file into bytecode and then executing that bytecode. The process of compiling a large application such as MediaWiki takes considerable time. PHP accelerators work by storing the compiled bytecode and executing it directly reducing the time spent compiling code.

OPcache is included in PHP 5.5.0 and later and the recommended accelerator for MediaWiki.

Opcode caches store the compiled output of PHP scripts, greatly reducing the amount of time needed to run a script multiple times. MediaWiki does not need to be configured to do PHP bytecode caching and will "just work" once installed and enabled them.

See $wgObjectCaches for an example of a custom cache backend (e.g. Redis).

  • It was stated that CACHE_MEMCACHED directive will provide the most significant performance improvements in the case where you have memcached and an opcode cache installed.
  • This is just one of MediaWiki's caching settings.
For best performance you may need to consider other caching settings. Siehe performance tuning .
  • Since MediaWiki 1.27, PHP sessions are stored in a cache, depending on the variable of this setting, unless overridden by $wgSessionCacheType . This may cause problems when CACHE_ACCEL is used if apcu is misconfigured (see T147161).

Login session problem with APCu in a multi process or multi server environment

$wgSessionCacheType inherits $wgMainCacheType unless configured otherwise.

Selecting CACHE_ACCEL as the cache type can cause inconsistent behavior where session data is lost, and the user must log back in. This is because php-fpm processes can be ephemeral or not good at talking to each other. There can also be problems in a multi-server environment.

The workaround is to use the database to store these sessions. Add the following line to LocalSettings.php

$wgSessionCacheType = CACHE_DB;

Siehe auch