Merge "Convert ForeignApiRepo::httpGetCached() to the WAN cache"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 27 Oct 2015 11:21:24 +0000 (11:21 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 27 Oct 2015 11:21:24 +0000 (11:21 +0000)
includes/filerepo/ForeignAPIRepo.php

index 3747e60..0a3314e 100644 (file)
@@ -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 ) {