并不需要每次都去清理日志,十分之一概率

This commit is contained in:
Anyon 2020-09-19 22:03:10 +08:00
parent da666da9ab
commit 84a8c3ab2e

View File

@ -27,8 +27,10 @@ app()->event->listen('HttpEnd', function () {
app()->db->name('SystemOplog')->insertAll($items);
}
$GLOBALS['oplogs'] = [];
$lastdate = date('Y-m-d H:i:s', strtotime('-7days'));
app()->db->name('SystemOplog')->where('create_at', '<', $lastdate)->delete();
if (rand(1, 100) <= 10) {
$lastdate = date('Y-m-d H:i:s', strtotime('-7days'));
app()->db->name('SystemOplog')->where('create_at', '<', $lastdate)->delete();
}
}
});