*
* - ObjectCache::getLocalServerInstance( $fallbackType )
* Purpose: Memory cache for very hot keys.
- * Stored only on the individual web server (typically APC for web requests,
+ * Stored only on the individual web server (typically APC or APCu for web requests,
* and EmptyBagOStuff in CLI mode).
* Not replicated to the other servers.
*
/**
* Factory function for CACHE_ACCEL (referenced from DefaultSettings.php)
*
- * This will look for any APC style server-local cache.
+ * This will look for any APC or APCu style server-local cache.
* A fallback cache can be specified if none is found.
*
* // Direct calls
public static function getLocalServerInstance( $fallback = CACHE_NONE ) {
if ( function_exists( 'apc_fetch' ) ) {
$id = 'apc';
+ } elseif ( function_exists( 'apcu_fetch' ) ) {
+ $id = 'apcu';
} elseif ( function_exists( 'xcache_get' ) && wfIniGetBool( 'xcache.var_size' ) ) {
$id = 'xcache';
} elseif ( function_exists( 'wincache_ucache_get' ) ) {
* @since 1.26
* @param string $id A key in $wgWANObjectCaches.
* @return WANObjectCache
- * @throws InvalidArgumentException
+ * @throws UnexpectedValueException
*/
public static function newWANCacheFromId( $id ) {
- global $wgWANObjectCaches;
+ global $wgWANObjectCaches, $wgObjectCaches;
if ( !isset( $wgWANObjectCaches[$id] ) ) {
- throw new InvalidArgumentException( "Invalid object cache type \"$id\" requested. " .
- "It is not present in \$wgWANObjectCaches." );
+ throw new UnexpectedValueException(
+ "Cache type \"$id\" requested is not present in \$wgWANObjectCaches." );
}
$params = $wgWANObjectCaches[$id];
+ if ( !isset( $wgObjectCaches[$params['cacheId']] ) ) {
+ throw new UnexpectedValueException(
+ "Cache type \"{$params['cacheId']}\" is not present in \$wgObjectCaches." );
+ }
+ $params['store'] = $wgObjectCaches[$params['cacheId']];
+
+ return self::newWANCacheFromParams( $params );
+ }
+
+ /**
+ * Create a new cache object of the specified type.
+ *
+ * @since 1.28
+ * @param array $params
+ * @return WANObjectCache
+ * @throws UnexpectedValueException
+ */
+ public static function newWANCacheFromParams( array $params ) {
foreach ( $params['channels'] as $action => $channel ) {
$params['relayers'][$action] = MediaWikiServices::getInstance()->getEventRelayerGroup()
->getRelayer( $channel );
$params['channels'][$action] = $channel;
}
- $params['cache'] = self::newFromId( $params['cacheId'] );
+ $params['cache'] = self::newFromParams( $params['store'] );
if ( isset( $params['loggroup'] ) ) {
$params['logger'] = LoggerFactory::getInstance( $params['loggroup'] );
} else {