I'm working on a project where doctrine cache is not active. We are experiencing some performance issues and I am wondering if activating doctrine cache would lead to possible regressions.
Here is why i'm asking about it:
I visualize the 3 cache type:
- metadata_cache_driver
- result_cache_driver
- query_cache_driver
The most important one for me is the result_cache_driver. And i'm not sure of how it works. Here is what I imagine:
We have an entity "book". If we create a dql query, or use findBy doctrine method to get all books written in 1975, it will return let says 75 books. This result is store in cache and next time we call it, it will not request the DB but get the result from cache.
Now we update the entity with DQL or doctrine ($book->setYear(1976)). I guess the cache for the entity book will be reset and next time we request for all book written in 1976 it will return 74 books.
Bu what if we update the DB using SQL: UPDATE book set year = 1976 where id = XXX. Will it clear the cache for this entity and request the DB when we ask for all book written in 1975? Or will it still use the cached result and return our updated book which is not in 1975 anymore?
To summarise, there are 3 way to update our DB:
- using doctrine entities (for single update)
- using dql query
- using sql query (for mass update)
So does the doctrine cache result take into account those 3 way? Or will there be some case we will have to wait the cache timelife end to get the new right result?