N°3764 - add transactions_gc_threshold in order to tune CSRF token GC load

This commit is contained in:
bruno-ds
2021-03-01 15:30:40 +01:00
parent 95a0efedcf
commit 0030d5c2b8
2 changed files with 16 additions and 0 deletions

View File

@@ -299,6 +299,14 @@ class privUITransactionFile
*/
protected static function CleanupOldTransactions($sTransactionDir = null)
{
$iThreshold = (int) MetaModel::GetConfig()->Get('transactions_gc_threshold');
$iThreshold = min(100, $iThreshold);
$iThreshold = max(1, $iThreshold);
if ((100 != $iThreshold) && (rand(1, 100) > $iThreshold)) {
return;
}
clearstatcache();
$iLimit = time() - 24*3600;
$sPattern = $sTransactionDir ? "$sTransactionDir/*" : APPROOT.'data/transactions/*';
$aTransactions = glob($sPattern);