first commit
This commit is contained in:
43
金壶/ydyd_service/application/command/CacheCommand.php
Normal file
43
金壶/ydyd_service/application/command/CacheCommand.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: zhuxiaowei
|
||||
* Date: 2019-03-19
|
||||
* Time: 09:28
|
||||
*/
|
||||
namespace app\command;
|
||||
use app\common\KeywordJson;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Exception;
|
||||
use think\facade\Cache;
|
||||
|
||||
class CacheCommand extends Command{
|
||||
|
||||
protected function configure(){
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user