[TYPO3-mvc] Calling persistAll() inside a loop

Franz Koch typo3.RemoveForMessage at elements-net.de
Thu Dec 30 00:12:06 CET 2010


Hey,

>> So i tried to call persistAll() after i added the category to the repository which leads me to two
>> problems:
>>
>> - First, the performance isn't very nice.
>> - Second, it seems that my fe_users are persisted more than one time
>
> I think you can persist single object, no need to persist everything.

AFAIK there is no API method for this, nor is there a public method you 
could call by hand messing with the PersistenceBackend.

> Anyway, your problem shows that the developer must be aware of the magic that is going on. Any query
> may return stale results if you have altered or added objects to the repository, but didn't persist
> the changes.

Even if the categories would be persisted immediately, there wouldn't be 
any performance boost compared to the local category cache. You ought to 
use the cache in any case, because every call to the repository will 
first trigger a MySQL statement even if the object already got fetched 
before - so there's more overhead without using a local cache.

But I agree that it's a bit odd that the repository doesn't know about 
newly added objects when using it in the same process. On the other hand 
- the only purposes where you could get in trouble with this are some 
sort of import tasks. In any other case the framework should work just 
fine without having to take care of this.
It's arguable if a repository->add/update/remove should instantly 
trigger the persistence - IIRC there was a discussion about this 
already, but I'm not sure.

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list