fix(reddit): increase default cache ttl (#4168)

This commit is contained in:
Dag 2024-07-29 00:18:28 +02:00 committed by GitHub
parent 8dd56bca05
commit 955fb6f315
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,7 @@ class RedditBridge extends BridgeAbstract
const MAINTAINER = 'dawidsowa';
const NAME = 'Reddit Bridge';
const URI = 'https://old.reddit.com';
const CACHE_TIMEOUT = 60 * 60 * 2; // 2h
const DESCRIPTION = 'Return hot submissions from Reddit';
const PARAMETERS = [
@ -107,9 +108,8 @@ class RedditBridge extends BridgeAbstract
// 403 Forbidden
// This can possibly mean that reddit has permanently blocked this server's ip address
$this->cache->set($forbiddenKey, true, 60 * 61);
}
if ($e->getCode() === 429) {
$this->cache->set($rateLimitKey, true, 60 * 16);
} elseif ($e->getCode() === 429) {
$this->cache->set($rateLimitKey, true, 60 * 61);
}
throw $e;
}
@ -143,10 +143,14 @@ class RedditBridge extends BridgeAbstract
$flareInput = $this->getInput('f');
foreach ($subreddits as $subreddit) {
$version = 'v0.0.1';
$version = 'v0.0.2';
$useragent = "rss-bridge $version (https://github.com/RSS-Bridge/rss-bridge)";
$url = self::createUrl($search, $flareInput, $subreddit, $user, $section, $this->queriedContext);
$json = getContents($url, ['User-Agent: ' . $useragent]);
$response = getContents($url, ['User-Agent: ' . $useragent], [], true);
$json = $response['content'];
$parsedJson = Json::decode($json, false);
foreach ($parsedJson->data->children as $post) {