IRON IO 대기열을 사용하는 flysystem을 사용하고 있으며, 약 1,800 만 건의 레코드와 약 5,000 건의 레코드를 가져 오는 DB 쿼리를 실행하려고합니다.phpleague flysystem 서버의 대용량 파일을 읽고 쓰십시오.
여기PHP Fatal error: Allowed memory size of ########## bytes exhausted
내가 싶습니다 단계는 다음과 같습니다 :
1) 데이터
2 가져가)를 돌려 여기에 내가 50 + MB의 파일 크기와 수신하고있는 오류 메시지는 를 CSV 적절한 문자열 (예 : implode(',', $dataArray) . "\r\n"
)
3)이 경우 (S3를 서버에서 파일을 가져 오기)
4) 파일 '내용을 읽어 보시기 바랍니다이 새로운 strin를 추가로 내가 믿고있어
public function fire($job, $data)
{
// First set the headers and write the initial file to server
$this->filesystem->write($this->filename, implode(',', $this->setHeaders($parameters)) . "\r\n", [
'visibility' => 'public',
'mimetype' => 'text/csv',
]);
// Loop to get new sets of data
$offset = 0;
while ($this->exportResult) {
$this->exportResult = $this->getData($parameters, $offset);
if ($this->exportResult) {
$this->writeToFile($this->exportResult);
$offset += 5000;
}
}
}
private function writeToFile($contentToBeAdded = '')
{
$content = $this->filesystem->read($this->filename);
// Append new data
$content .= $contentToBeAdded;
$this->filesystem->update($this->filename, $content, [
'visibility' => 'public'
]);
}
이 가장 효율적이지 않다 : 그것과에 g S3 파일 여기
간단한 실행이 내가 가지고있는 코드 아래입니다 해당 내용을 다시 쓰기? 나는이 문서들에서 벗어날 것이다. PHPLeague Flysystem
누군가가 더 적절한 방향으로 나를 가리킬 수 있다면, 그것은 굉장 할 것이다!
이 Flysystem를 사용하여 파일에 추가 할 수있는 방법이 있는가 확인하시기 바랍니다? 그렇지 않으면 나는 당신이 어떻게 많은 양의 메모리를 사용하는 것을 피할 수 있는지 보지 못한다. – andy
@andy 아니 거기에있는 것처럼 보이지 않습니다. 그들은 스트림 기능을 가지고 있지만 그 내용을 업데이 트하기 위해 파일을 읽어야하는 것과 같은 방식으로 작동한다고 생각합니다. –