mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-13 18:38:48 +00:00
[core] Remove hardcoded maximum duration of 24 hours in loadCacheValue (#3355)
This commit is contained in:
parent
a4a7473abb
commit
343fd36671
@ -159,7 +159,7 @@ class BugzillaBridge extends BridgeAbstract
|
|||||||
protected function getUser($user)
|
protected function getUser($user)
|
||||||
{
|
{
|
||||||
// Check if the user endpoint is available
|
// Check if the user endpoint is available
|
||||||
if ($this->loadCacheValue($this->instance . 'userEndpointClosed')) {
|
if ($this->loadCacheValue($this->instance . 'userEndpointClosed', 86400)) {
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ The default URI shows the Madara demo page.';
|
|||||||
protected function getMangaInfo($url)
|
protected function getMangaInfo($url)
|
||||||
{
|
{
|
||||||
$url_cache = 'TitleInfo_' . preg_replace('/[^\w]/', '.', rtrim($url, '/'));
|
$url_cache = 'TitleInfo_' . preg_replace('/[^\w]/', '.', rtrim($url, '/'));
|
||||||
$cache = $this->loadCacheValue($url_cache);
|
$cache = $this->loadCacheValue($url_cache, 86400);
|
||||||
if (isset($cache)) {
|
if (isset($cache)) {
|
||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
|
@ -489,11 +489,11 @@ public function collectData()
|
|||||||
Within the context of the current bridge, loads a value by key from cache. Optionally specifies the cache duration for the key. Returns `null` if the key doesn't exist or the value is expired.
|
Within the context of the current bridge, loads a value by key from cache. Optionally specifies the cache duration for the key. Returns `null` if the key doesn't exist or the value is expired.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
protected function loadCacheValue($key, $duration = 86400)
|
protected function loadCacheValue($key, $duration = null)
|
||||||
```
|
```
|
||||||
|
|
||||||
- `$key` - the name under which the value is stored in the cache.
|
- `$key` - the name under which the value is stored in the cache.
|
||||||
- `$duration` - the maximum time in seconds after which the value expires. The default duration is 86400 (24 hours).
|
- `$duration` - the maximum time in seconds after which the value expires.
|
||||||
|
|
||||||
Usage example:
|
Usage example:
|
||||||
|
|
||||||
|
@ -409,10 +409,10 @@ abstract class BridgeAbstract implements BridgeInterface
|
|||||||
* Loads a cached value for the specified key
|
* Loads a cached value for the specified key
|
||||||
*
|
*
|
||||||
* @param string $key Key name
|
* @param string $key Key name
|
||||||
* @param int $duration Cache duration (optional, default: 24 hours)
|
* @param int $duration Cache duration (optional)
|
||||||
* @return mixed Cached value or null if the key doesn't exist or has expired
|
* @return mixed Cached value or null if the key doesn't exist or has expired
|
||||||
*/
|
*/
|
||||||
protected function loadCacheValue($key, int $duration = 86400)
|
protected function loadCacheValue($key, $duration = null)
|
||||||
{
|
{
|
||||||
$cacheFactory = new CacheFactory();
|
$cacheFactory = new CacheFactory();
|
||||||
|
|
||||||
@ -421,7 +421,7 @@ abstract class BridgeAbstract implements BridgeInterface
|
|||||||
$scope = $this->getShortName();
|
$scope = $this->getShortName();
|
||||||
$cache->setScope($scope);
|
$cache->setScope($scope);
|
||||||
$cache->setKey($key);
|
$cache->setKey($key);
|
||||||
if ($cache->getTime() < time() - $duration) {
|
if ($duration && $cache->getTime() < time() - $duration) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return $cache->loadData();
|
return $cache->loadData();
|
||||||
|
Loading…
Reference in New Issue
Block a user