Remove "always" cache-creating files when it's related cache has not been accesed 7 days
This commit is contained in:
parent
45b3e5cb15
commit
f09df04fd3
18
cron.php
18
cron.php
|
@ -109,13 +109,27 @@ function run__cronjobs_cache_cleanup() {
|
|||
unlink($cache_dir.'/'.$fl);
|
||||
}
|
||||
}
|
||||
$dir = $GLOBALS['appconf']['data_dir'].'/cron/db';
|
||||
$crondb_dir = $GLOBALS['appconf']['data_dir'].'/cron/db';
|
||||
foreach (scandir($crondb_dir) as $fl) {
|
||||
if (in_array($fl, ['.','..']))
|
||||
continue;
|
||||
$cron_file = $crondb_dir.'/'.$fl;
|
||||
$data = @unserialize(file_get_contents($cron_file));
|
||||
if ($data === false || !isset($data['last_accessed']))
|
||||
continue;
|
||||
$ms = time() - $data['last_accessed'];
|
||||
$days_diff = intval($ms / 60 / 60 / 24);
|
||||
if ($days_diff >= 7) {
|
||||
logi('CACHE-CLEANUP remove cron/db cache creator file: '.$fl);
|
||||
unlink($cron_file);
|
||||
}
|
||||
}
|
||||
foreach ($others as $fl) {
|
||||
$ps = explode(',',$fl);
|
||||
if (count($ps) === 2 && $ps[1] === 'always') {
|
||||
$id = $ps[0];
|
||||
$contains = false;
|
||||
foreach (scandir($dir) as $f) {
|
||||
foreach (scandir($crondb_dir) as $f) {
|
||||
if (in_array($f, ['.','..']))
|
||||
continue;
|
||||
if (strpos($f, ','.$id.',') !== false) {
|
||||
|
|
Loading…
Reference in New Issue