We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

PHQL caching control

Hi

I saw below line in PHQL docs:

PHQL statements are parsed once and cached in memory. Further executions of the same statement result in a slightly faster execution

I have some questions:

  • Is it enabled by default?

  • How much time PHQL commands do remain in cache?

  • How I can control PHQL cache?

  • is it possible to cache PHQL results instead of statements?

  • If prev question has positive asnwer then: How can I know if current PHQL result is from cache?

Thank you.



98.9k
Accepted
answer
edited Aug '14

Is it enabled by default?

Yes

How much time PHQL commands do remain in cache?

Just for the time the request lasts.

How I can control PHQL cache?

You can't control it, all parsed statements are stored in the temporary memory of the request.

is it possible to cache PHQL results instead of statements?

Yes, check this chapter of the documentation: https://docs.phalcon.io/en/latest/reference/models-cache.html

If prev question has positive asnwer then: How can I know if current PHQL result is from cache?

Depending on the caching approach you choose for your application you can introduce debug information to know this.