[TYPO3-mvc] Flush persistence cache

roberto blanko robertoblanko at gmail.com
Wed Jul 7 13:11:16 CEST 2010


Hello list,

lets say I'm fetching an object from a repository like this. $myFirstField =
$fieldRepository->findOneByUid(4711);

Now I'm changing some attributes in the resulting object which are
intentionally excluded from being persisted to DB.

Now I'm fetching the same DB record again:

$mySecondField = $fieldRepository->findOneByUid(4711);

The resulting object $mySecondField still has the changed non-DB-attributes
from $myFirstField. However I want $mySecondField to be read from DB again.
So my assumpotion is, that Extbase caches objects once they've been
registered for the first time. Is there a way to get rid of all cached
instances?

Something like that:

$myFirstField = $fieldRepository->findOneByUid(4711);
// Do something with $myFirstField
$fieldRepository->flushRegisteredObjects();
$mySecondField = $fieldRepository->findOneByUid(4711);
// $mySecondField is freshly fetched from DB again without having the
changes of $myFirstField

Please don't ask me about the whole context of this or why mySecondField
cannot be the same like myFirstField. It's a damn complicated application
which unfortunately takes Extbase to its limits.

Thanks in advance for all the feedback!


More information about the TYPO3-project-typo3v4mvc mailing list