2
當我使用一個蒙戈DB光標在PHP中:MongoDB的光標和內存
$Cursor = \MyDocument::find();
foreach ($Cursor as $Document)
$Document->doSomething();
有那麼只有在記憶中留下的最後$文檔或我必須刪除光標對象內置文件?
當我使用一個蒙戈DB光標在PHP中:MongoDB的光標和內存
$Cursor = \MyDocument::find();
foreach ($Cursor as $Document)
$Document->doSomething();
有那麼只有在記憶中留下的最後$文檔或我必須刪除光標對象內置文件?
基本上,只有$Document
將在內存中,這是foreach
迭代中的當前內存。
只要你沒有遇到實際內存問題,我會留下它與這個簡化的描述。
另請參閱:MongoDB - Why should I use a cursor instead of iterator_to_array (in PHP)。
MongoCursor class documentation也解釋了這一點。
謝謝!沒事兒… – stofl