<?php namespace Illuminate\Cache\Console; use Illuminate\Console\Command; use Illuminate\Cache\CacheManager; use Symfony\Component\Console\Input\InputArgument; // namespace to done class ClearCommand extends Command {// ClearCommand to extends /** * The console command name. * * @var string */ protected $name = ‘cache:clear‘;// The console command name. /** * The console command description. * * @var string */ protected $description = ‘Flush the application cache‘;// description /** * The cache manager instance. * * @var \Illuminate\Cache\CacheManager */ protected $cache;// a cache manager instance. /** * Create a new cache clear command instance. * * @param \Illuminate\Cache\CacheManager $cache * @return void */ public function __construct(CacheManager $cache) { parent::__construct();// father $this->cache = $cache;// set cache }// create a new cache clear command instance /** * Execute the console command. * * @return void */ public function fire()// fire is execute the event { $storeName = $this->argument(‘store‘);// argument method to get the store Name $this->laravel[‘events‘]->fire(‘cache:clearing‘, [$storeName]);// a store array ,the value is a instance $this->cache->store($storeName)->flush();// remove all,delete $this->laravel[‘events‘]->fire(‘cache:cleared‘, [$storeName]);// fire a event $this->info(‘Application cache cleared!‘);// log info } /** * Get the console command arguments. * * @return array */ protected function getArguments()// Get the console command arguments { return [ [‘store‘, InputArgument::OPTIONAL, ‘The name of the store you would like to clear.‘], ]; }// get Arguments method }
时间: 2024-12-23 01:03:09