Vali Munteanu
Vali Munteanu

Reputation: 488

Does Zend TableGateway automatically cache duplicated queries?

I remember reading something similar about Symfony's Doctrine, but I can't find anything about this in Zend 2 documentation.

Here is the question explained:

Let's say that in a single controller action I call two model functions (both in same model): both functions run exactly the same TableGateway query sets. These queries only SELECT data. Furthermore there are no INSERT/UPDATE operations anywhere in this action.

In this case, would Zend run the query sets twice? Or, seeing that they are duplicated and no INSERT/UPDATE operation is done in-between, it would run the query set just once, and the second time return it from some internal cache.

ps. Just in case, please understand that I don't need general best practice advice, just the specific answer from someone who knows the depths of Zend's core.

Upvotes: 0

Views: 79

Answers (1)

Andrew
Andrew

Reputation: 12809

No. It would be bad to do that anyway as your application has no idea if another application has written to the database and invalidated your cached query.

If you have query cache enabled in my sql then the query could be cached as the rdbms knows if that data can be cached or if it's been changed.

Upvotes: 0

Related Questions