setName('CacheCommand')->setDescription("华源商品缓存");//这里的setName和php文件名一致,setDescription随意 } /* * 测试 */ protected function execute(Input $input, Output $output) { Cache::set('test', 1); Cache::rm('test'); //华源商品抓取 try{ $json = KeywordJson::getJson(); $keyList = json_decode($json,true); foreach ($keyList as $key=>$value) { Cache::set('huayuangoods_'.$key,$value); } echo "华源商品缓存重制完成 \n"; }catch (Exception $exception){ echo $exception->getMessage()." \n"; return; } } }