Merge "Converted User object cache to the WAN cache"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 18 May 2015 06:38:06 +0000 (06:38 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 18 May 2015 06:38:06 +0000 (06:38 +0000)
includes/User.php
includes/UserRightsProxy.php

index a2be2f0..7902119 100644 (file)
@@ -410,15 +410,14 @@ class User implements IDBAccessObject {
         * @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 @@ class User implements IDBAccessObject {
         * This method should not be called outside the User class
         */
        public function saveToCache() {
-               global $wgMemc;
-
                $this->load();
                $this->loadGroups();
                $this->loadOptions();
@@ -451,6 +448,8 @@ class User implements IDBAccessObject {
                        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.
                if ( !( $this->queryFlagsUsed & self::READ_LATEST ) ) {
@@ -465,7 +464,7 @@ class User implements IDBAccessObject {
                $data['mVersion'] = self::VERSION;
                $key = wfMemcKey( 'user', 'id', $this->mId );
 
-               $wgMemc->set( $key, $data );
+               $cache->set( $key, $data );
        }
 
        /** @name newFrom*() static factory methods */
@@ -2302,11 +2301,11 @@ class User implements IDBAccessObject {
         * 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 ) );
                }
        }
 
index 1b9e4b6..a19f698 100644 (file)
@@ -278,8 +278,8 @@ class UserRightsProxy {
                        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 );
        }
 }