mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-23 15:06:53 +00:00
[index] Add new global parameter '_cache_timeout'
The _cache_timeout parameter is an optional parameter that can be used to specify a custom cache timeout. This option is enabled by default. It can be disabled using the named constant 'CUSTOM_CACHE_TIMEOUT' which supports two states: > true: Enabled (default) > false: Disabled
This commit is contained in:
parent
72691eee67
commit
877b123838
16
index.php
16
index.php
@ -19,6 +19,10 @@ define('PROXY_BYBRIDGE', false);
|
|||||||
// Comment this line or keep PROXY_NAME empty to display PROXY_URL instead
|
// Comment this line or keep PROXY_NAME empty to display PROXY_URL instead
|
||||||
define('PROXY_NAME', 'Hidden Proxy Name');
|
define('PROXY_NAME', 'Hidden Proxy Name');
|
||||||
|
|
||||||
|
// Allows the operator to specify custom cache timeouts via '&_cache_timeout=3600'
|
||||||
|
// true: enabled (default), false: disabled
|
||||||
|
define('CUSTOM_CACHE_TIMEOUT', true);
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
|
|
||||||
@ -168,6 +172,16 @@ try {
|
|||||||
define('NOPROXY', true);
|
define('NOPROXY', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom cache timeout
|
||||||
|
$cache_timeout = -1;
|
||||||
|
if(array_key_exists('_cache_timeout', $params)) {
|
||||||
|
if(!CUSTOM_CACHE_TIMEOUT) {
|
||||||
|
throw new \HttpException('This server doesn\'t support "_cache_timeout"!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$cache_timeout = filter_var($params['_cache_timeout'], FILTER_VALIDATE_INT);
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize cache
|
// Initialize cache
|
||||||
$cache = Cache::create('FileCache');
|
$cache = Cache::create('FileCache');
|
||||||
$cache->setPath(CACHE_DIR);
|
$cache->setPath(CACHE_DIR);
|
||||||
@ -178,10 +192,12 @@ try {
|
|||||||
unset($params['bridge']);
|
unset($params['bridge']);
|
||||||
unset($params['format']);
|
unset($params['format']);
|
||||||
unset($params['_noproxy']);
|
unset($params['_noproxy']);
|
||||||
|
unset($params['_cache_timeout']);
|
||||||
|
|
||||||
// Load cache & data
|
// Load cache & data
|
||||||
try {
|
try {
|
||||||
$bridge->setCache($cache);
|
$bridge->setCache($cache);
|
||||||
|
$bridge->setCacheTimeout($cache_timeout);
|
||||||
$bridge->setDatas($params);
|
$bridge->setDatas($params);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
http_response_code($e->getCode());
|
http_response_code($e->getCode());
|
||||||
|
Loading…
Reference in New Issue
Block a user