parser: Convert wikitext Preprocessor class to using WAN cache
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 28 Feb 2019 20:54:49 +0000 (12:54 -0800)
committerKrinkle <krinklemail@gmail.com>
Fri, 12 Apr 2019 20:52:49 +0000 (20:52 +0000)
Change-Id: Ida96a976109f7ceee0003b9d1d487c8cf9b80114

includes/parser/Preprocessor.php

index b6084d8..bdfedd6 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
 
 /**
  * @ingroup Parser
@@ -73,10 +74,12 @@ abstract class Preprocessor {
                        return;
                }
 
-               $cache = ObjectCache::getLocalClusterInstance();
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
                $key = $cache->makeKey(
                        defined( 'static::CACHE_PREFIX' ) ? static::CACHE_PREFIX : static::class,
-                       md5( $text ), $flags );
+                       md5( $text ),
+                       $flags
+               );
                $value = sprintf( "%08d", static::CACHE_VERSION ) . $tree;
 
                $cache->set( $key, $value, 86400 );
@@ -102,11 +105,13 @@ abstract class Preprocessor {
                        return false;
                }
 
-               $cache = ObjectCache::getLocalClusterInstance();
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
 
                $key = $cache->makeKey(
                        defined( 'static::CACHE_PREFIX' ) ? static::CACHE_PREFIX : static::class,
-                       md5( $text ), $flags );
+                       md5( $text ),
+                       $flags
+               );
 
                $value = $cache->get( $key );
                if ( !$value ) {