app/Console/Commands/UpdateCache2.php
/**
     * Execute the console command.
     *
     * @return mixed
     */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function handle()
    {
        $this->info('update cache 2');
         大淘客
        $url = sprintf(env('DATAOKE_KEY_API_TOP100_URL'), env('DATAOKE_KEY_API_KEY'));
        $client = new Client();
        $response = $client->request('GET', $url);
        if ($response->getStatusCode() == 200) {
            if ($response->getBody()) {
                $result  =  \GuzzleHttp\json_decode($response->getBody());
                if(isset($result->result)){
                    $data = $result->result;
                    $arr = [];  4 * 5
                    $index = 0;
                    foreach ($data as $item) {
                        if ($index > 19) {
                            break;
                        }
                        $arr[$index]['id'] = $item->ID;
                        $arr[$index]['title']  = $item->Title;
                        $arr[$index]['d_title']  = $item->D_title;
                        $arr[$index]['d_title']  = $item->D_title;
                        $arr[$index]['pic']  = $item->Pic;
                        $arr[$index]['category_id']  = $item->Cid;
                        $index ++ ;
                    }
                    Cache::put('movie:quan_ad_list',$arr, 60*1+3);   1 小时 + 3分钟
                }
            }
        }
    }
public function handle ( ) { $ this -> info ( 'update cache 2' ) ; $ url = sprintf ( env ( 'DATAOKE_KEY_API_TOP100_URL' ) , env ( 'DATAOKE_KEY_API_KEY' ) ) ; $ client = new Client ( ) ; $ response = $ client -> request ( 'GET' , $ url ) ; if ( $ response -> getStatusCode ( ) == 200 ) { if ( $ response -> getBody ( ) ) { $ result = \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) ; if ( isset ( $ result -> result ) ) { $ data = $ result -> result ; $ arr = [ ] ; $ index = 0 ; foreach ( $ data as $ item ) { if ( $ index > 19 ) { break ; } $ arr [ $ index ] [ 'id' ] = $ item -> ID ; $ arr [ $ index ] [ 'title' ] = $ item -> Title ; $ arr [ $ index ] [ 'd_title' ] = $ item -> D_title ; $ arr [ $ index ] [ 'd_title' ] = $ item -> D_title ; $ arr [ $ index ] [ 'pic' ] = $ item -> Pic ; $ arr [ $ index ] [ 'category_id' ] = $ item -> Cid ; $ index ++ ; } Cache :: put ( 'movie:quan_ad_list' , $ arr , 60 * 1 + 3 ) ; } } } }
Execute the console command.
Execute the console command .
// // 大淘客 // 4 * 5 // 1 小时 + 3分钟