From b739bf5a74b6017ed45351dc72f28522cd7af859 Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Fri, 9 Oct 2015 16:26:26 -0700 Subject: [PATCH] Add ObjectCache::getMainClusterInstance() Provide a complement to ObjectCache::getMainWANInstance() and ObjectCache::getMainStashInstance() which gets the default ObjectCache instance. Change-Id: Ib16ee40908b159e60be41a308db49a9291b5de0d --- includes/objectcache/ObjectCache.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php index 70e97ff148..c40f69613f 100644 --- a/includes/objectcache/ObjectCache.php +++ b/includes/objectcache/ObjectCache.php @@ -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. * -- 2.20.1