From 82a5b40ab2f183db1a1d1f4946e6327b0e28ee7f Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Tue, 27 Sep 2022 21:48:57 -0400 Subject: GentooPackages: Use ObjectCache directly Replace deprecated CacheHelper Signed-off-by: Brian Evans --- GentooPackages/GentooPackages.php | 22 ++++++++++++++++------ 1 file 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']; } } -- cgit v1.2.3-65-gdbad