From cb862afaf38c3d04fe374cae5327d1e7203b8fa7 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 19 Oct 2015 10:56:41 -0700 Subject: [PATCH] Rename getMainClusterInstance() -> getLocalClusterInstance() Also corrected some ObjectCache docs Change-Id: I322f4cbd72fbd5d4c6887d90ee75d0baddb6ac25 --- includes/GlobalFunctions.php | 6 +++--- includes/objectcache/ObjectCache.php | 18 +++++++++--------- .../includes/GlobalFunctions/GlobalTest.php | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a3b1e55e2b..e73c75cb49 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3559,7 +3559,7 @@ function wfGetPrecompiledData( $name ) { */ function wfMemcKey( /*...*/ ) { return call_user_func_array( - array( ObjectCache::getMainClusterInstance(), 'makeKey' ), + array( ObjectCache::getLocalClusterInstance(), 'makeKey' ), func_get_args() ); } @@ -3578,7 +3578,7 @@ function wfForeignMemcKey( $db, $prefix /*...*/ ) { $args = array_slice( func_get_args(), 2 ); $keyspace = $prefix ? "$db-$prefix" : $db; return call_user_func_array( - array( ObjectCache::getMainClusterInstance(), 'makeKeyInternal' ), + array( ObjectCache::getLocalClusterInstance(), 'makeKeyInternal' ), array( $keyspace, $args ) ); } @@ -3596,7 +3596,7 @@ function wfForeignMemcKey( $db, $prefix /*...*/ ) { */ function wfGlobalCacheKey( /*...*/ ) { return call_user_func_array( - array( ObjectCache::getMainClusterInstance(), 'makeGlobalKey' ), + array( ObjectCache::getLocalClusterInstance(), 'makeGlobalKey' ), func_get_args() ); } diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php index 098247a6cc..3665c11681 100644 --- a/includes/objectcache/ObjectCache.php +++ b/includes/objectcache/ObjectCache.php @@ -47,12 +47,6 @@ use MediaWiki\Logger\LoggerFactory; * Stored only on the individual web server. * Not associated with other servers. * - * - ObjectCache::getMainClusterInstance() - * 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. - * * - ObjectCache::getMainWANInstance() * Purpose: Cache. * Stored in the local data-center's main cache (uses different cache keys). @@ -60,11 +54,17 @@ use MediaWiki\Logger\LoggerFactory; * * - ObjectCache::getMainStashInstance() * Purpose: Ephemeral storage. - * Stored centrally within the local data-center. - * Changes are replicated to other DCs (eventually consistent). + * 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. * This store may be subject to LRU style evictions. * + * - ObjectCache::getLocalClusterInstance() + * Purpose: Memory storage for per-cluster coordination and tracking. + * A typical use case would be a rate limit counter or cache regeneration mutex. + * Stored centrally within the local data-center. Not replicated to other DCs. + * Also known as $wgMemc. Configured by $wgMainCacheType. + * * - wfGetCache( $cacheType ) * Get a specific cache type by key in $wgObjectCaches. * @@ -298,7 +298,7 @@ class ObjectCache { * @since 1.27 * @return BagOStuff */ - public static function getMainClusterInstance() { + public static function getLocalClusterInstance() { global $wgMainCacheType; return self::getInstance( $wgMainCacheType ); diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php index 913c82f1e5..56f97469ae 100644 --- a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php +++ b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php @@ -707,7 +707,7 @@ class GlobalTest extends MediaWikiTestCase { } public function testWfMemcKey() { - $cache = ObjectCache::getMainClusterInstance(); + $cache = ObjectCache::getLocalClusterInstance(); $this->assertEquals( $cache->makeKey( 'foo', 123, 'bar' ), wfMemcKey( 'foo', 123, 'bar' ) @@ -715,7 +715,7 @@ class GlobalTest extends MediaWikiTestCase { } public function testWfForeignMemcKey() { - $cache = ObjectCache::getMainClusterInstance(); + $cache = ObjectCache::getLocalClusterInstance(); $keyspace = $this->readAttribute( $cache, 'keyspace' ); $this->assertEquals( wfForeignMemcKey( $keyspace, '', 'foo', 'bar' ), @@ -724,7 +724,7 @@ class GlobalTest extends MediaWikiTestCase { } public function testWfGlobalCacheKey() { - $cache = ObjectCache::getMainClusterInstance(); + $cache = ObjectCache::getLocalClusterInstance(); $this->assertEquals( $cache->makeGlobalKey( 'foo', 123, 'bar' ), wfGlobalCacheKey( 'foo', 123, 'bar' ) -- 2.20.1