post = $post; } /** * Execute the console command. * * @return mixed */ public function handle() { $this->line("开始更新内容信息"); $bar = $this->output->createProgressBar($this->post->withTrashed()->count()); $this->post->withTrashed()->chunk(100, function($posts) use ($bar){ foreach($posts as $post){ $bar->advance(); if(!$post->data) continue; Redis::HSET('post_info_'.$post->id, 'id', $post->id, 'uid', $post->uid, 'type', $post->type, 'img', $post->img, 'imgs', json_encode(array_column($post->imgs->toArray(), 'img')), 'video', $post->video, 'topic_ids', $post->topic_ids, 'title', $post->title, 'content', $post->content, 'location', $post->location, 'pv', $post->data->pv, 'dislike_count', $post->data->dislike_count, 'praise_count', $post->data->praise_count, 'share_count', $post->data->share_count, 'comment_count', $post->data->comment_count, 'collect_count', $post->data->collect_count, 'available_bean', $post->data->available_bean, 'will_collect_bean', $post->data->will_collect_bean, 'create_bean', $post->data->create_bean, 'collect_bean', $post->data->collect_bean, 'created_at', $post->created_at); } usleep(100000); }); $bar->finish(); $this->line("\n更新内容信息结束"); } }