1
votes

note : sorry for my poor English, I am French but I will try to be as clear as possible.

I am getting into Doctrine2 with Symfony2. Just making a little game for the fun to learn new stuff and test these new awesome tools. Here is my deal : I want to store my game configuration into database (like items, race information, etc.) to benefit from the handy syntax of entities :

$user->getRace()->getName();

The point is the "Race" or the "Item" information are not likely to change. I found out the @ReadOnly entity annotation that tells Doctrine not to check updates in these entities after the first insert. I am wondering if you knew a way to 'transparently' (I mean doctrine does it for me) cache these results to prevent useless joins each time I retrieve my user information.

1

1 Answers

4
votes

Only thing that @ReadOnly annotation does is it tells Doctrine not to update the entity on flush. Event if it was changed it's not updated.

So it has little to do with querying.

If you want to cache the Race or Item objects you should utilize the result cache. It enables you to cache result of the any query.

To make it easier to use (and reusable) you might implement custom annotation which would make that query for referenced entity uses result cache automatically.