* Primary entry points:
*
* - ObjectCache::newAccelerator( $fallbackType )
- * Purpose: Cache.
+ * Purpose: Cache for very hot keys.
* Stored only on the individual web server.
* Not associated with other servers.
*
* - ObjectCache::getMainClusterInstance()
- * Purpose: Cache.
+ * Purpose: Memory storage for per-cluster coordination and tracking.
* Stored centrally within the local data-center.
* Not replicated to other DCs.
* Also known as $wgMemc. Configured by $wgMainCacheType.
* @ingroup Cache
*/
class ObjectCache {
- /** @var Array Map of (id => BagOStuff) */
+ /** @var BagOStuff[] Map of (id => BagOStuff) */
public static $instances = array();
-
- /** @var Array Map of (id => WANObjectCache) */
+ /** @var WANObjectCache[] Map of (id => WANObjectCache) */
public static $wanInstances = array();
/**
return self::newFromParams( $wgObjectCaches[$id] );
}
+ /**
+ * Get the default keyspace for this wiki.
+ *
+ * This is either the value of the `CachePrefix` configuration variable,
+ * or (if the former is unset) the `DBname` configuration variable, with
+ * `DBprefix` (if defined).
+ *
+ * @return string
+ */
+ public static function getDefaultKeyspace() {
+ global $wgCachePrefix, $wgDBname, $wgDBprefix;
+
+ $keyspace = $wgCachePrefix;
+ if ( is_string( $keyspace ) && $keyspace !== '' ) {
+ return $keyspace;
+ }
+
+ $keyspace = $wgDBname;
+ if ( is_string( $wgDBprefix ) && $wgDBprefix !== '' ) {
+ $keyspace .= '-' . $wgDBprefix;
+ }
+
+ return $keyspace;
+ }
+
/**
* Create a new cache object from parameters.
*
// have all logging suddenly disappear
$params['logger'] = LoggerFactory::getInstance( 'objectcache' );
}
+ if ( !isset( $params['keyspace'] ) ) {
+ $params['keyspace'] = self::getDefaultKeyspace();
+ }
if ( isset( $params['factory'] ) ) {
return call_user_func( $params['factory'], $params );
} elseif ( isset( $params['class'] ) ) {
* @return BagOStuff
*/
public static function getMainClusterInstance() {
- $config = RequestContext::getMain()->getConfig();
- $id = $config->get( 'MainCacheType' );
- return self::getInstance( $id );
+ global $wgMainCacheType;
+
+ return self::getInstance( $wgMainCacheType );
}
/**