From: Aaron Schulz Date: Wed, 29 Apr 2015 22:03:09 +0000 (-0700) Subject: Converted Interwiki using WAN cache X-Git-Tag: 1.31.0-rc.0~11459^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=4a74dbf1988d86e500c2855fc0ab8f18a99c38cd;p=lhc%2Fweb%2Fwiklou.git Converted Interwiki using WAN cache * Added an invalidateCache() method for the Interwiki extension Bug: T93141 Change-Id: Id4f8b6fb9bfe26f6b5e5ce32e4e55d51eb37964d --- diff --git a/includes/interwiki/Interwiki.php b/includes/interwiki/Interwiki.php index 02fbb0802b..33e506686e 100644 --- a/includes/interwiki/Interwiki.php +++ b/includes/interwiki/Interwiki.php @@ -114,6 +114,17 @@ class Interwiki { return $iw; } + /** + * Purge the cache for an interwiki prefix + * @param string $prefix + * @since 1.26 + */ + public static function invalidateCache( $prefix ) { + $cache = ObjectCache::getMainWANInstance(); + $key = wfMemcKey( 'interwiki', $prefix ); + $cache->delete( $key ); + } + /** * Fetch interwiki prefix data from local cache in constant database. * @@ -191,16 +202,18 @@ class Interwiki { * @return Interwiki|bool Interwiki if $prefix is valid, otherwise false */ protected static function load( $prefix ) { - global $wgMemc, $wgInterwikiExpiry; + global $wgInterwikiExpiry; $iwData = array(); if ( !Hooks::run( 'InterwikiLoadPrefix', array( $prefix, &$iwData ) ) ) { return Interwiki::loadFromArray( $iwData ); } + $cache = ObjectCache::getMainWANInstance(); + if ( !$iwData ) { $key = wfMemcKey( 'interwiki', $prefix ); - $iwData = $wgMemc->get( $key ); + $iwData = $cache->get( $key ); if ( $iwData === '!NONEXISTENT' ) { // negative cache hit return false; @@ -232,13 +245,13 @@ class Interwiki { 'iw_local' => $iw->mLocal, 'iw_trans' => $iw->mTrans ); - $wgMemc->add( $key, $mc, $wgInterwikiExpiry ); + $cache->set( $key, $mc, $wgInterwikiExpiry ); return $iw; } // negative cache hit - $wgMemc->add( $key, '!NONEXISTENT', $wgInterwikiExpiry ); + $cache->set( $key, '!NONEXISTENT', $wgInterwikiExpiry ); return false; }