aboutsummaryrefslogtreecommitdiffstats
path: root/includes/filerepo/ForeignAPIRepo.php
diff options
context:
space:
mode:
authorMáté Szabó <mszabo@wikia-inc.com>2021-06-21 22:32:49 +0200
committerMáté Szabó <mszabo@fandom.com>2022-08-19 14:01:10 +0200
commitd232d3da617783ffdcc787fd7c3b72d0a22165e8 (patch)
tree0e03c4b3f09a5c9d8c1d9e5e8cb61be8db8a6d75 /includes/filerepo/ForeignAPIRepo.php
parent137460d576d9668fdc5f7111fe06f3c584011ae0 (diff)
downloadmediawikicore-d232d3da617783ffdcc787fd7c3b72d0a22165e8.tar.gz
mediawikicore-d232d3da617783ffdcc787fd7c3b72d0a22165e8.zip
filerepo: Allow shared caching of ForeignAPIRepo responses across wikis
Currently, ForeignAPIRepo caches image metadata and siteinfo in memcached, with the keys being local to the client wiki. This can result in a low hit ratio if the same ForeignAPIRepo is shared between multiple wikis. Since the cache keys for image metadata and site info already vary on the foreign URL being fetched, it should be possible to make these cache keys global and thereby allow reusing them across wikis that share the same file repo configuration. This is similar to what ForeignDBRepo/ForeignDBFile do already, although note that for those classes the getSharedCacheKey() calls are not in their own source, but inherited from LocalRepo/LocalFile. Bug: T285271 Change-Id: Iaa20a27893e9748cb42fa3a3beb7cd4669b461cb
Diffstat (limited to 'includes/filerepo/ForeignAPIRepo.php')
-rw-r--r--includes/filerepo/ForeignAPIRepo.php5
1 files changed, 4 insertions, 1 deletions
diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php
index 5015645351f0..b98c240a93c8 100644
--- a/includes/filerepo/ForeignAPIRepo.php
+++ b/includes/filerepo/ForeignAPIRepo.php
@@ -592,7 +592,10 @@ class ForeignAPIRepo extends FileRepo implements IForeignRepoWithMWApi {
}
return $this->wanCache->getWithSetCallback(
- $this->getLocalCacheKey( $attribute, sha1( $url ) ),
+ // Allow reusing the same cached data across wikis (T285271).
+ // This does not use getSharedCacheKey() because caching here
+ // is transparent to client wikis (which are not expected to issue purges).
+ $this->wanCache->makeGlobalKey( "filerepo-$attribute", sha1( $url ) ),
$cacheTTL,
function ( $curValue, &$ttl ) use ( $url ) {
$html = self::httpGet( $url, 'default', [], $mtime );