summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2022-09-27 21:48:57 -0400
committerBrian Evans <grknight@gentoo.org>2022-09-27 21:48:57 -0400
commit82a5b40ab2f183db1a1d1f4946e6327b0e28ee7f (patch)
treefcf94a60ab58630a320a39218fc1f52a3ab1e004
parentGentooToolbox: Mark updateDataBefore as static (diff)
downloadextensions-82a5b40ab2f183db1a1d1f4946e6327b0e28ee7f.tar.gz
extensions-82a5b40ab2f183db1a1d1f4946e6327b0e28ee7f.tar.bz2
extensions-82a5b40ab2f183db1a1d1f4946e6327b0e28ee7f.zip
GentooPackages: Use ObjectCache directly
Replace deprecated CacheHelper Signed-off-by: Brian Evans <grknight@gentoo.org>
-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'];
}
}