From 14e377083c820b5ad1868a61696107de45042dd4 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 26 Oct 2015 01:05:08 -0700 Subject: [PATCH] Convert ForeignApiRepo::httpGetCached() to the WAN cache Change-Id: I4f1098a6e98570fc4fea6941ffcd64540d6caebd --- includes/filerepo/ForeignAPIRepo.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index 4ffbf4add2..38305dca1b 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -552,19 +552,16 @@ class ForeignAPIRepo extends FileRepo { } if ( !isset( $this->mQueryCache[$url] ) ) { - global $wgMemc; - - $key = $this->getLocalCacheKey( get_class( $this ), $target, md5( $url ) ); - $data = $wgMemc->get( $key ); - - if ( !$data ) { - $data = self::httpGet( $url ); - - if ( !$data ) { - return null; + $data = ObjectCache::getMainWANInstance()->getWithSetCallback( + $this->getLocalCacheKey( get_class( $this ), $target, md5( $url ) ), + $cacheTTL, + function () use ( $url ) { + return ForeignAPIRepo::httpGet( $url ); } + ); - $wgMemc->set( $key, $data, $cacheTTL ); + if ( !$data ) { + return null; } if ( count( $this->mQueryCache ) > 100 ) { -- 2.20.1