function drush_cache_command_clear

8.0.x cache.drush.inc drush_cache_command_clear($type = NULL)
6.x cache.drush.inc drush_cache_command_clear($type = NULL)
7.x cache.drush.inc drush_cache_command_clear($type = NULL)
5.x cache.drush.inc drush_cache_command_clear($type = NULL)
master cache.drush.inc drush_cache_command_clear($type = NULL)

Command callback for drush cache-clear.

1 string reference to 'drush_cache_command_clear'
cache_drush_command in commands/core/cache.drush.inc
Implementation of hook_drush_command().

File

commands/core/cache.drush.inc, line 126

Code

function drush_cache_command_clear($type = NULL) {
  if (!drush_get_option('cache-clear', TRUE)) {
    drush_log(dt("Skipping cache-clear operation due to --cache-clear=0 option."), LogLevel::OK);
    return TRUE;
  }
  $types = drush_cache_clear_types(drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL));

  if (!isset($type)) {
    // Don't offer 'all' unless Drush has bootstrapped the Drupal site
    if (!drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
      unset($types['all']);
    }
    $type = drush_choice($types, 'Enter a number to choose which cache to clear.', '!key');
    if (empty($type)) {
      return drush_user_abort();
    }
  }
  // Do it.
  drush_op($types[$type]);
  if ($type == 'all' && !drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
    drush_log(dt("No Drupal site found, only 'drush' cache was cleared."), LogLevel::WARNING);
  }
  else {
    drush_log(dt("'!name' cache was cleared.", array('!name' => $type)), LogLevel::SUCCESS);
  }
}