Remove old visitors in single process

This commit is contained in:
Dmitriy Simushev 2014-10-31 11:26:53 +00:00
parent f10079497c
commit f0c4299ba3

View File

@ -21,6 +21,7 @@
use Mibew\EventDispatcher\EventDispatcher;
use Mibew\EventDispatcher\Events;
use Mibew\Database;
use Mibew\ProcessLock;
use Mibew\Settings;
use Mibew\Thread;
@ -196,6 +197,8 @@ function track_retrieve_details($visitor)
*/
function track_remove_old_visitors()
{
$lock = new ProcessLock('visitors_remove_old');
if ($lock->get()) {
$db = Database::getInstance();
// Remove associations of visitors with closed threads
@ -218,6 +221,10 @@ function track_remove_old_visitors()
':now' => time(),
)
);
// Release the lock
$lock->release();
}
}
/**