You are here

function db_maintenance_cron in DB Maintenance 8.2

Same name and namespace in other branches
  1. 8 db_maintenance.module \db_maintenance_cron()
  2. 5.2 db_maintenance.module \db_maintenance_cron()
  3. 5 db_maintenance.module \db_maintenance_cron()
  4. 6.2 db_maintenance.module \db_maintenance_cron()
  5. 6 db_maintenance.module \db_maintenance_cron()
  6. 7.2 db_maintenance.module \db_maintenance_cron()
  7. 7 db_maintenance.module \db_maintenance_cron()
  8. 2.0.x db_maintenance.module \db_maintenance_cron()

Implements hook_cron().

File

./db_maintenance.module, line 136
Optimizes database tables during cron runs.

Code

function db_maintenance_cron() {
  $last_run = \Drupal::config('db_maintenance.settings')
    ->get('db_maintenance_cron_last');
  $interval = REQUEST_TIME - \Drupal::config('db_maintenance.settings')
    ->get('db_maintenance_cron_frequency');

  // Only run cron if enough time has elapsed.
  if ($interval > $last_run) {
    db_maintenance_optimize_tables();
  }
}