feat: add a cache breaking route
This commit is contained in:
@@ -10,6 +10,7 @@ $instance = $config['mastodon-instance'];
|
||||
$uid = $config['user-id'];
|
||||
$searchurl = $config['search-url'];
|
||||
$search = isset($_GET['search']) ? strtolower($_GET['search']) : '';
|
||||
$force_refresh = isset($_GET['force_refresh']) && $_GET['force_refresh'] == '1';
|
||||
$debug_on = $config['debug'];
|
||||
/* cache files */
|
||||
$ctt = $config['cache_toots'];
|
||||
@@ -17,6 +18,19 @@ $dbt = "cache-toots.json";
|
||||
$ctc = $config['cache_comments'];
|
||||
$dbc = "cache-comments_%id.json";
|
||||
|
||||
/* Force cache refresh if requested */
|
||||
if ($force_refresh) {
|
||||
debug("Force refresh requested - clearing toot cache");
|
||||
if (file_exists($dbt)) {
|
||||
unlink($dbt);
|
||||
}
|
||||
// Also clear all comment cache files
|
||||
foreach (glob("cache-comments_*.json") as $cache_file) {
|
||||
unlink($cache_file);
|
||||
debug("Deleted cache file: $cache_file");
|
||||
}
|
||||
}
|
||||
|
||||
/* Exit if search empty */
|
||||
if (empty($search)) {
|
||||
debug("No proper search given");
|
||||
@@ -158,7 +172,7 @@ function tootContextAndStats($instance, $id, &$result) {
|
||||
|
||||
/* check whether the cached file containing all toots is older than max. cache time */
|
||||
// this at the same time loads the cached DB, either way
|
||||
$cachebreak = false;
|
||||
$cachebreak = $force_refresh; // Force cache break if requested
|
||||
read_db($dbt, $toots, $ctt, $cachebreak, false);
|
||||
|
||||
if ($cachebreak) {
|
||||
|
||||
Reference in New Issue
Block a user