Add ObjectCache::getMainClusterInstance()
authorOri Livneh <ori@wikimedia.org>
Fri, 9 Oct 2015 23:26:26 +0000 (16:26 -0700)
committerOri.livneh <ori@wikimedia.org>
Sat, 10 Oct 2015 00:48:33 +0000 (00:48 +0000)
Provide a complement to ObjectCache::getMainWANInstance() and
ObjectCache::getMainStashInstance() which gets the default ObjectCache
instance.

Change-Id: Ib16ee40908b159e60be41a308db49a9291b5de0d

includes/objectcache/ObjectCache.php

index 70e97ff..c40f696 100644 (file)
@@ -47,7 +47,7 @@ use MediaWiki\Logger\LoggerFactory;
  *   Stored only on the individual web server.
  *   Not associated with other servers.
  *
- * - wfGetMainCache()
+ * - ObjectCache::getMainClusterInstance()
  *   Purpose: Cache.
  *   Stored centrally within the local data-center.
  *   Not replicated to other DCs.
@@ -261,6 +261,18 @@ class ObjectCache {
                return new $class( $params );
        }
 
+       /**
+        * Get the main cluster-local cache object.
+        *
+        * @since 1.27
+        * @return BagOStuff
+        */
+       public static function getMainClusterInstance() {
+               $config = RequestContext::getMain()->getConfig();
+               $id = $config->get( 'MainCacheType' );
+               return self::getInstance( $id );
+       }
+
        /**
         * Get the main WAN cache object.
         *