summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'GentooPackages/GentooPackages.php')
-rw-r--r--GentooPackages/GentooPackages.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/GentooPackages/GentooPackages.php b/GentooPackages/GentooPackages.php
index d287b920..2e3ff3e1 100644
--- a/GentooPackages/GentooPackages.php
+++ b/GentooPackages/GentooPackages.php
@@ -9,15 +9,25 @@ class GentooPackages { // implements MediaWiki\Hook\ParserFirstCallInitHook {
if ($atom === NULL) {
return "Package name missing";
}
- $cache = new CacheHelper();
- $cache->setExpiry(60 * 60 * 24); // 1 day
- $cache->setCacheKey(['packageInfo', $atom, $type]);
+ $cacheExpiry = 60 * 60 * 24; // 1 day
+ $cacheKey = ['packageInfo', $atom, $type];
+ $cacheKeyString = ObjectCache::getLocalClusterInstance()->makeKey(...array_values( $cacheKey ));
try {
- $packageInfo = $cache->getCachedValue('self::fetchOrError', [$atom, $type]);
- $cache->saveCache();
+ $packageInfo = '';
+ $objCache = ObjectCache::getInstance( CACHE_ANYTHING );
+ $cacheChunks = $objCache->get($cacheKeyString);
+ if ( !empty($cacheChunks) && is_array($cacheChunks) ) {
+ $packageInfo = array_shift( $cacheChunks );
+ }
+ if ( empty( $packageInfo ) ) {
+ $packageInfo = static::fetchOrError($atom, $type);
+ $cacheChunks = [ $packageInfo ];
+ $objCache->set($cacheKeyString, $cacheChunks, $cacheExpiry);
+ }
+
return [$packageInfo, 'markerType' => 'nowiki'];
} catch (Exception $ex) {
- return [$ex->message, 'markerType' => 'nowiki'];
+ return [$ex->getMessage(), 'markerType' => 'nowiki'];
}
}