profileId = $profileId; $this->followType = $followType; } /** * Execute the job. * * @return void */ public function handle() { $pid = $this->profileId; $type = $this->followType; if($type === 'followers') { $key = 'follow-warm-cache/' . $pid . '/followers.json'; if(!Storage::exists($key)) { return; } $file = Storage::get($key); $json = json_decode($file, true); foreach($json as $id) { FollowerService::add($id, $pid, false); usleep(random_int(500, 3000)); } sleep(5); Storage::delete($key); } if($type === 'following') { $key = 'follow-warm-cache/' . $pid . '/following.json'; if(!Storage::exists($key)) { return; } $file = Storage::get($key); $json = json_decode($file, true); foreach($json as $id) { FollowerService::add($pid, $id, false); usleep(random_int(500, 3000)); } sleep(5); Storage::delete($key); } sleep(random_int(2, 5)); $files = Storage::files('follow-warm-cache/' . $pid); if(empty($files)) { Storage::deleteDirectory('follow-warm-cache/' . $pid); } } }