mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-16 21:58:21 +01:00
fix(reddit): increase default cache ttl (#4168)
This commit is contained in:
parent
8dd56bca05
commit
955fb6f315
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user