예제 #1
0
 /**
  * {@inheritdoc}
  */
 protected function fire()
 {
     ee()->lang->loadfile('ce_cache', 'ce_cache');
     $items = $this->argument('items');
     $tags = $this->option('tags');
     // if there are no arguments, clear all caches
     if (!$items) {
         require_once PATH_THIRD . 'ce_cache/libraries/Ce_cache_factory.php';
         $drivers = \Ce_cache_factory::factory(array('file', 'db', 'static', 'apc', 'memcache', 'memcached', 'redis', 'dummy'));
         foreach ($drivers as $driver) {
             $driverName = lang('ce_cache_driver_' . $driver->name());
             if ($driver->clear() === false) {
                 $this->error(sprintf(lang('ce_cache_error_cleaning_driver_cache'), $driverName));
             } else {
                 $this->comment($driverName . ' cache cleared.');
             }
         }
     } else {
         require_once PATH_THIRD . 'ce_cache/libraries/Ce_cache_break.php';
         $breaker = new \Ce_cache_break();
         $name = $tags ? 'Tag' : 'Item';
         $which = $tags ? 1 : 0;
         $defaultArgs = array(array(), array(), false);
         foreach ($items as $item) {
             $args = $defaultArgs;
             $args[$which][] = $item;
             call_user_func_array(array($breaker, 'break_cache'), $args);
             $this->comment($name . ' ' . $item . ' cleared.');
         }
     }
     $this->info('CE Cache cleared.');
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 protected function fire()
 {
     ee()->lang->loadfile('ce_cache', 'ce_cache');
     $items = $this->argument('items');
     $tags = $this->option('tags');
     $drivers = $this->option('driver');
     $refresh = $this->option('refresh') ? true : false;
     $refresh_time = $this->option('refresh_time');
     $defaultDrivers = array('file', 'db', 'static', 'apc', 'memcache', 'memcached', 'redis', 'dummy');
     if ($drivers) {
         $invalidDrivers = array_diff($drivers, $defaultDrivers);
         if ($invalidDrivers) {
             throw new \RuntimeException('Invalid driver(s) specified: ' . implode(', ', $invalidDrivers));
         }
         $drivers = array_intersect($drivers, $defaultDrivers);
     } else {
         $drivers = $defaultDrivers;
     }
     // if there are no arguments, clear all caches
     if (!$items) {
         require_once PATH_THIRD . 'ce_cache/libraries/Ce_cache_factory.php';
         $drivers = \Ce_cache_factory::factory($drivers);
         foreach ($drivers as $driver) {
             $driverName = lang('ce_cache_driver_' . $driver->name());
             if ($driver->clear() === false) {
                 $this->error(sprintf(lang('ce_cache_error_cleaning_driver_cache'), $driverName));
             } else {
                 $this->comment($driverName . ' cache cleared.');
             }
         }
     } else {
         require_once PATH_THIRD . 'ce_cache/libraries/Ce_cache_break.php';
         $breaker = new \Ce_cache_break();
         $name = $tags ? 'Tag' : 'Item';
         $which = $tags ? 1 : 0;
         $time = $refresh_time ?: 1;
         $defaultArgs = array(array(), array(), $refresh, $time);
         foreach ($items as $item) {
             $args = $defaultArgs;
             $args[$which][] = $item;
             call_user_func_array(array($breaker, 'break_cache'), $args);
             $this->comment($name . ' ' . $item . ' cleared.');
             if ($refresh) {
                 $this->comment($name . ' ' . $item . ' will be refreshed');
             }
         }
     }
     $this->info('CE Cache cleared.');
 }