1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-07-31 13:50:23 +02:00

fix: rewrite and improve caching (#3594)

This commit is contained in:
Dag
2023-09-10 21:50:15 +02:00
committed by GitHub
parent a786bbd4e0
commit 4b9f6f7e53
45 changed files with 993 additions and 1169 deletions

View File

@@ -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