Cache clearing rearrangements
This commit is contained in:
@@ -63,9 +63,6 @@ class Cron
|
||||
// Call possible post update functions
|
||||
Worker::add(PRIORITY_LOW, 'PostUpdate');
|
||||
|
||||
// Clear cache entries
|
||||
Worker::add(PRIORITY_LOW, 'ClearCache');
|
||||
|
||||
// Repair entries in the database
|
||||
Worker::add(PRIORITY_LOW, 'RepairDatabase');
|
||||
|
||||
@@ -94,6 +91,10 @@ class Cron
|
||||
|
||||
self::checkdeletedContacts();
|
||||
|
||||
if (!DI::config()->get('system', 'optimize_tables')) {
|
||||
self::optimizeTables();
|
||||
}
|
||||
|
||||
DI::config()->set('system', 'last_expire_day', $d2);
|
||||
}
|
||||
|
||||
@@ -110,9 +111,20 @@ class Cron
|
||||
|
||||
// Optimizing this table only last seconds
|
||||
if (DI::config()->get('system', 'optimize_tables')) {
|
||||
DBA::e("OPTIMIZE TABLE `workerqueue`");
|
||||
// We are acquiring the two locks from the worker to avoid locking problems
|
||||
if (DI::lock()->acquire(Worker::LOCK_PROCESS, 10)) {
|
||||
if (DI::lock()->acquire(Worker::LOCK_WORKER, 10)) {
|
||||
DBA::e("OPTIMIZE TABLE `workerqueue`");
|
||||
DBA::e("OPTIMIZE TABLE `process`");
|
||||
DI::lock()->release(Worker::LOCK_WORKER);
|
||||
}
|
||||
DI::lock()->release(Worker::LOCK_PROCESS);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear cache entries
|
||||
Worker::add(PRIORITY_LOW, 'ClearCache');
|
||||
|
||||
DI::config()->set('system', 'last_cron_hourly', time());
|
||||
}
|
||||
|
||||
@@ -136,6 +148,25 @@ class Cron
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimize tables that are known to grow and shrink all the time
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function optimizeTables()
|
||||
{
|
||||
Logger::info('Optimize start');
|
||||
|
||||
DBA::e("OPTIMIZE TABLE `auth_codes`");
|
||||
DBA::e("OPTIMIZE TABLE `challenge`");
|
||||
DBA::e("OPTIMIZE TABLE `locks`");
|
||||
DBA::e("OPTIMIZE TABLE `profile_check`");
|
||||
DBA::e("OPTIMIZE TABLE `session`");
|
||||
DBA::e("OPTIMIZE TABLE `tokens`");
|
||||
|
||||
DI::lock()->release('optimize_tables');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for contacts that are about to be deleted and ensures that they are removed.
|
||||
* This should be done automatically in the "remove" function. This here is a cleanup job.
|
||||
|
||||
Reference in New Issue
Block a user