jenkins-bot has submitted this change and it was merged. Change subject: Converted User object cache to the WAN cache ......................................................................
Converted User object cache to the WAN cache Bug: T93141 Change-Id: I93dc5367d85d661bd5bdce29f4665bb8cd21ba02 --- M includes/User.php M includes/UserRightsProxy.php 2 files changed, 10 insertions(+), 11 deletions(-) Approvals: Gilles: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/User.php b/includes/User.php index c3d4a65..1936efd 100644 --- a/includes/User.php +++ b/includes/User.php @@ -410,15 +410,14 @@ * @since 1.25 */ protected function loadFromCache() { - global $wgMemc; - if ( $this->mId == 0 ) { $this->loadDefaults(); return false; } + $cache = ObjectCache::getMainWANInstance(); $key = wfMemcKey( 'user', 'id', $this->mId ); - $data = $wgMemc->get( $key ); + $data = $cache->get( $key ); if ( !is_array( $data ) || $data['mVersion'] < self::VERSION ) { // Object is expired return false; @@ -440,8 +439,6 @@ * This method should not be called outside the User class */ public function saveToCache() { - global $wgMemc; - $this->load(); $this->loadGroups(); $this->loadOptions(); @@ -450,6 +447,8 @@ // Anonymous users are uncached return; } + + $cache = ObjectCache::getMainWANInstance(); // The cache needs good consistency due to its high TTL, so the user // should have been loaded from the master to avoid lag amplification. @@ -465,7 +464,7 @@ $data['mVersion'] = self::VERSION; $key = wfMemcKey( 'user', 'id', $this->mId ); - $wgMemc->set( $key, $data ); + $cache->set( $key, $data ); } /** @name newFrom*() static factory methods */ @@ -2310,11 +2309,11 @@ * Called implicitly from invalidateCache() and saveSettings(). */ public function clearSharedCache() { - global $wgMemc; - $this->load(); if ( $this->mId ) { - $wgMemc->delete( wfMemcKey( 'user', 'id', $this->mId ) ); + $cache = ObjectCache::getMainWANInstance(); + + $cache->delete( wfMemcKey( 'user', 'id', $this->mId ) ); } } diff --git a/includes/UserRightsProxy.php b/includes/UserRightsProxy.php index 1b9e4b69..a19f698 100644 --- a/includes/UserRightsProxy.php +++ b/includes/UserRightsProxy.php @@ -278,8 +278,8 @@ array( 'user_id' => $this->id ), __METHOD__ ); - global $wgMemc; + $cache = ObjectCache::getMainWANInstance(); $key = wfForeignMemcKey( $this->database, false, 'user', 'id', $this->id ); - $wgMemc->delete( $key ); + $cache->delete( $key ); } } -- To view, visit https://gerrit.wikimedia.org/r/207001 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I93dc5367d85d661bd5bdce29f4665bb8cd21ba02 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Gilles <gdu...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits