Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.



85.4k
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: http://docs.phalconphp.com/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.