diff options
author | 2023-09-10 21:50:15 +0200 | |
---|---|---|
committer | 2023-09-10 21:50:15 +0200 | |
commit | 4b9f6f7e53e0b2e9aae59df2bbffc0bdd6805aea (patch) | |
tree | 40bc3e62a343df8bd0076b609d57248f7bd9448b /lib/BridgeAbstract.php | |
parent | a786bbd4e0d45a98446ed0384ed57705a17b89d3 (diff) | |
download | rss-bridge-4b9f6f7e53e0b2e9aae59df2bbffc0bdd6805aea.tar.gz rss-bridge-4b9f6f7e53e0b2e9aae59df2bbffc0bdd6805aea.tar.zst rss-bridge-4b9f6f7e53e0b2e9aae59df2bbffc0bdd6805aea.zip |
fix: rewrite and improve caching (#3594)
Diffstat (limited to 'lib/BridgeAbstract.php')
-rw-r--r-- | lib/BridgeAbstract.php | 19 |
1 files changed, 10 insertions, 9 deletions
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 |