请问下 Laravel 7 如果使用 Command 多线程?
$chapterDetail[‘img’],是远程同步图片地址,但是数据大约200W条 挨条处理是在太慢!服务器16H 32G 8T 硬件没有任何问题!请问下如何写多线程! 要不然200w条数据同步2个月时间太长了
/*同步内容图片*/
ini_set('memory_limit', '-1');
foreach (ChapterDetail::all() as $chapterDetail)
{
if (strpos($chapterDetail['img'],'http://')===0 || strpos($chapterDetail['img'],'https://')===0)
{
$getChapterDetailPicUrlPicUrl = Http::get($chapterDetail['img'])->body();
$chapterDetailPicUrl='/images/'.now()->timestamp.rand(000000000,999999999).'.jpg';
Storage::disk('public')->put($chapterDetailPicUrl,$getChapterDetailPicUrlPicUrl);
$chapterDetail->update(['img'=>'/storage/'.$chapterDetailPicUrl]);
}
}
$this->info('全部图片同步完成');