You are here

function apc_drush_flush in APC - Alternative PHP Cache 7

XMLRPC callback to enable cache clear from Drush/CLI.

1 string reference to 'apc_drush_flush'
apc_xmlrpc in ./apc.module
Implements hook_xmlrpc().

File

./apc.module, line 22
This integrates the drupal APC cache module.

Code

function apc_drush_flush($variables) {
  $cron_key = isset($variables['cron_key']) ? $variables['cron_key'] : NULL;
  $clears = isset($variables['clears']) ? $variables['clears'] : array();
  if (empty($cron_key) || variable_get('cron_key', 'drupal') != $cron_key) {
    watchdog('apc', 'APC could not flush cache(s) because an invalid key was used.', array(), WATCHDOG_ERROR);
    return array(
      'success' => FALSE,
      'message' => t('APC could not flush cache(s) because an invalid key was used.'),
    );
  }
  else {
    foreach ($clears as $bin => $cids) {
      $cache = _cache_get_object($bin);
      foreach ($cids as $serialized_cid => $wildcard) {
        $cache
          ->clear(unserialize($serialized_cid), $wildcard);
      }
    }
    return array(
      'success' => TRUE,
      'message' => t('APC all requested flushes done.'),
    );
  }
}