mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-15 04:54:01 +02:00
fix: rewrite and improve caching (#3594)
This commit is contained in:
@@ -279,10 +279,9 @@ class SpotifyBridge extends BridgeAbstract
|
||||
private function fetchAccessToken()
|
||||
{
|
||||
$cache = RssBridge::getCache();
|
||||
$cacheKey = sprintf('%s:%s', $this->getInput('clientid'), $this->getInput('clientsecret'));
|
||||
$cache->setScope('SpotifyBridge');
|
||||
$cache->setKey([$cacheKey]);
|
||||
$token = $cache->loadData(3600);
|
||||
$cacheKey = sprintf('SpotifyBridge:%s:%s', $this->getInput('clientid'), $this->getInput('clientsecret'));
|
||||
|
||||
$token = $cache->get($cacheKey);
|
||||
if ($token) {
|
||||
$this->token = $token;
|
||||
} else {
|
||||
@@ -294,9 +293,8 @@ class SpotifyBridge extends BridgeAbstract
|
||||
]);
|
||||
$data = Json::decode($json);
|
||||
$this->token = $data['access_token'];
|
||||
$cache->setScope('SpotifyBridge');
|
||||
$cache->setKey([$cacheKey]);
|
||||
$cache->saveData($this->token);
|
||||
|
||||
$cache->set($cacheKey, $this->token, 3600);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user