Merge "Converted ChangeTags to using the WAN cache"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 7 May 2015 19:30:24 +0000 (19:30 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 7 May 2015 19:30:24 +0000 (19:30 +0000)
includes/changetags/ChangeTags.php

index a0c3cf2..64f89bf 100644 (file)
@@ -1064,10 +1064,10 @@ class ChangeTags {
         * @since 1.25
         */
        public static function listExtensionActivatedTags() {
-               // Caching...
-               global $wgMemc;
+               $cache = ObjectCache::getMainWANInstance();
+
                $key = wfMemcKey( 'active-tags' );
-               $tags = $wgMemc->get( $key );
+               $tags = $cache->get( $key );
                if ( $tags ) {
                        return $tags;
                }
@@ -1077,7 +1077,8 @@ class ChangeTags {
                Hooks::run( 'ChangeTagsListActive', array( &$extensionActive ) );
 
                // Short-term caching.
-               $wgMemc->set( $key, $extensionActive, 300 );
+               $cache->set( $key, $extensionActive, 300 );
+
                return $extensionActive;
        }
 
@@ -1105,10 +1106,10 @@ class ChangeTags {
         * @since 1.25
         */
        public static function listExplicitlyDefinedTags() {
-               // Caching...
-               global $wgMemc;
+               $cache = ObjectCache::getMainWANInstance();
+
                $key = wfMemcKey( 'valid-tags-db' );
-               $tags = $wgMemc->get( $key );
+               $tags = $cache->get( $key );
                if ( $tags ) {
                        return $tags;
                }
@@ -1125,7 +1126,8 @@ class ChangeTags {
                $emptyTags = array_filter( array_unique( $emptyTags ) );
 
                // Short-term caching.
-               $wgMemc->set( $key, $emptyTags, 300 );
+               $cache->set( $key, $emptyTags, 300 );
+
                return $emptyTags;
        }
 
@@ -1139,10 +1141,10 @@ class ChangeTags {
         * @since 1.25
         */
        public static function listExtensionDefinedTags() {
-               // Caching...
-               global $wgMemc;
+               $cache = ObjectCache::getMainWANInstance();
+
                $key = wfMemcKey( 'valid-tags-hook' );
-               $tags = $wgMemc->get( $key );
+               $tags = $cache->get( $key );
                if ( $tags ) {
                        return $tags;
                }
@@ -1152,7 +1154,8 @@ class ChangeTags {
                $emptyTags = array_filter( array_unique( $emptyTags ) );
 
                // Short-term caching.
-               $wgMemc->set( $key, $emptyTags, 300 );
+               $cache->set( $key, $emptyTags, 300 );
+
                return $emptyTags;
        }
 
@@ -1162,10 +1165,12 @@ class ChangeTags {
         * @since 1.25
         */
        public static function purgeTagCacheAll() {
-               global $wgMemc;
-               $wgMemc->delete( wfMemcKey( 'active-tags' ) );
-               $wgMemc->delete( wfMemcKey( 'valid-tags-db' ) );
-               $wgMemc->delete( wfMemcKey( 'valid-tags-hook' ) );
+               $cache = ObjectCache::getMainWANInstance();
+
+               $cache->delete( wfMemcKey( 'active-tags' ) );
+               $cache->delete( wfMemcKey( 'valid-tags-db' ) );
+               $cache->delete( wfMemcKey( 'valid-tags-hook' ) );
+
                self::purgeTagUsageCache();
        }
 
@@ -1174,8 +1179,9 @@ class ChangeTags {
         * @since 1.25
         */
        public static function purgeTagUsageCache() {
-               global $wgMemc;
-               $wgMemc->delete( wfMemcKey( 'change-tag-statistics' ) );
+               $cache = ObjectCache::getMainWANInstance();
+
+               $cache->delete( wfMemcKey( 'change-tag-statistics' ) );
        }
 
        /**
@@ -1188,10 +1194,10 @@ class ChangeTags {
         * @return array Array of string => int
         */
        public static function tagUsageStatistics() {
-               // Caching...
-               global $wgMemc;
+               $cache = ObjectCache::getMainWANInstance();
+
                $key = wfMemcKey( 'change-tag-statistics' );
-               $stats = $wgMemc->get( $key );
+               $stats = $cache->get( $key );
                if ( $stats ) {
                        return $stats;
                }
@@ -1217,7 +1223,8 @@ class ChangeTags {
                }
 
                // Cache for a very short time
-               $wgMemc->set( $key, $out, 300 );
+               $cache->set( $key, $out, 300 );
+
                return $out;
        }