*
* - ObjectCache::getMainWANInstance()
* Purpose: Memory cache.
- * Stored in the local data-center's main cache (uses different cache keys).
- * Delete events are broadcasted to other DCs. See WANObjectCache for details.
+ * Stored in the local data-center's main cache (keyspace different from local-cluster cache).
+ * Delete events are broadcasted to other DCs main cache. See WANObjectCache for details.
*
* - ObjectCache::getLocalServerInstance( $fallbackType )
* Purpose: Memory cache for very hot keys.
- * Stored only on the individual web server (often EmptyBagOStuff in CLI mode).
+ * Stored only on the individual web server (typically APC for web requests,
+ * and EmptyBagOStuff in CLI mode).
* Not replicated to the other servers.
*
* - ObjectCache::getLocalClusterInstance()
* Purpose: Ephemeral global storage.
* Stored centrally within the primary data-center.
* Changes are applied there first and replicated to other DCs (best-effort).
- * To retrieve the latest value (e.g. not from a slave), use BagOStuff:READ_LATEST.
+ * To retrieve the latest value (e.g. not from a slave), use BagOStuff::READ_LATEST.
* This store may be subject to LRU style evictions.
*
* - ObjectCache::getInstance( $cacheType )
*/
class ObjectCache {
/** @var BagOStuff[] Map of (id => BagOStuff) */
- public static $instances = array();
+ public static $instances = [];
/** @var WANObjectCache[] Map of (id => WANObjectCache) */
- public static $wanInstances = array();
+ public static $wanInstances = [];
/**
* Get a cached instance of the specified type of cache object.
* @return string
*/
public static function getDefaultKeyspace() {
- global $wgCachePrefix, $wgDBname, $wgDBprefix;
+ global $wgCachePrefix;
$keyspace = $wgCachePrefix;
if ( is_string( $keyspace ) && $keyspace !== '' ) {
return $keyspace;
}
- $keyspace = $wgDBname;
- if ( is_string( $wgDBprefix ) && $wgDBprefix !== '' ) {
- $keyspace .= '-' . $wgDBprefix;
- }
-
- return $keyspace;
+ return wfWikiID();
}
/**
} elseif ( isset( $params['class'] ) ) {
$class = $params['class'];
// Automatically set the 'async' update handler
- if ( $class === 'MultiWriteBagOStuff' ) {
- $params['asyncHandler'] = isset( $params['asyncHandler'] )
- ? $params['asyncHandler']
- : 'DeferredUpdates::addCallableUpdate';
- }
+ $params['asyncHandler'] = isset( $params['asyncHandler'] )
+ ? $params['asyncHandler']
+ : 'DeferredUpdates::addCallableUpdate';
+ // Enable reportDupes by default
+ $params['reportDupes'] = isset( $params['reportDupes'] )
+ ? $params['reportDupes']
+ : true;
// Do b/c logic for MemcachedBagOStuff
if ( is_subclass_of( $class, 'MemcachedBagOStuff' ) ) {
if ( !isset( $params['servers'] ) ) {
*/
public static function newAnything( $params ) {
global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType;
- $candidates = array( $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType );
+ $candidates = [ $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType ];
foreach ( $candidates as $candidate ) {
if ( $candidate !== CACHE_NONE && $candidate !== CACHE_ANYTHING ) {
return self::getInstance( $candidate );
* @return BagOStuff
* @deprecated 1.27
*/
- public static function newAccelerator( $params = array(), $fallback = null ) {
+ public static function newAccelerator( $params = [], $fallback = null ) {
if ( $fallback === null ) {
- // The is_array check here is needed because in PHP 5.3:
- // $a = 'hash'; isset( $params['fallback'] ); yields true
if ( is_array( $params ) && isset( $params['fallback'] ) ) {
$fallback = $params['fallback'];
} elseif ( !is_array( $params ) ) {
* Clear all the cached instances.
*/
public static function clear() {
- self::$instances = array();
- self::$wanInstances = array();
+ self::$instances = [];
+ self::$wanInstances = [];
}
}