Open LouTerrailloune opened 10 years ago
I would rather change the default value form true
to false
.
Not sure it's a good idea to set 'truncate' to false by default. Some people are certainly using it like that (truncating the table).
Setting truncate to false if $index is passed to the constructor is just a small BC break (because if people are using $index, they already called setTruncate(false)
).
Another solution is to remove the test in findOrCreateItem()
and check for in memory objects. (duplicate will be avoided)
@LouTerrailloune You are right, it might not be the best idea. I only want to avoid side effects or some magic. I'm okay with that if you leave a note in the docblock and Readme.
To your second solution: Its a great idea, but i think this will the grown up the memory usage. Doctrine does the same and if you have a large object graph (~10000 Objects) you have a huge memory usage.
This is why don't use the DoctrineWriter
only for rare cases.
For second solution: the batch size is here to limit memory usage. We need to keep a reference to the objects in the batch only (+ the key), and we do the query too. When we flush a batch, we remove our reference, the object can be removed from memory since they are not referenced anymore.
Shall we disable it automatically when something is passed in $index ? (otherwise $index is ignored if we don't call
setTruncate(false)
.