From 4b9f6f7e53e0b2e9aae59df2bbffc0bdd6805aea Mon Sep 17 00:00:00 2001 From: Dag Date: Sun, 10 Sep 2023 21:50:15 +0200 Subject: fix: rewrite and improve caching (#3594) --- lib/BridgeAbstract.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lib/BridgeAbstract.php') diff --git a/lib/BridgeAbstract.php b/lib/BridgeAbstract.php index 2a6cd8ab..36a77669 100644 --- a/lib/BridgeAbstract.php +++ b/lib/BridgeAbstract.php @@ -116,6 +116,10 @@ abstract class BridgeAbstract implements BridgeInterface */ private array $configuration = []; + public function __construct() + { + } + /** {@inheritdoc} */ public function getItems() { @@ -410,15 +414,13 @@ abstract class BridgeAbstract implements BridgeInterface /** * Loads a cached value for the specified key * - * @param int $timeout Cache duration (optional) * @return mixed Cached value or null if the key doesn't exist or has expired */ - protected function loadCacheValue(string $key, int $timeout = 86400) + protected function loadCacheValue(string $key) { $cache = RssBridge::getCache(); - $cache->setScope($this->getShortName()); - $cache->setKey([$key]); - return $cache->loadData($timeout); + $cacheKey = $this->getShortName() . '_' . $key; + return $cache->get($cacheKey); } /** @@ -426,12 +428,11 @@ abstract class BridgeAbstract implements BridgeInterface * * @param mixed $value Value to cache */ - protected function saveCacheValue(string $key, $value) + protected function saveCacheValue(string $key, $value, $ttl = 86400) { $cache = RssBridge::getCache(); - $cache->setScope($this->getShortName()); - $cache->setKey([$key]); - $cache->saveData($value); + $cacheKey = $this->getShortName() . '_' . $key; + $cache->set($cacheKey, $value, $ttl); } public function getShortName(): string -- cgit v1.2.3