I tested this with Doctrine 2.3 using:
$q->setResultCacheDriver( new \Doctrine\Common\Cache\ApcCache() ) ->setResultCacheLifetime( 21600 ) ->setResultCacheId( 'user_' . $identity );
When I run it for the first time, I see the actual query in my sql-logger.
When I run this second, third, etc., I do not see anything in my sql-logger.
My conclusion is that it works fine.
I think that you either do not have a result cache configured, or you have an inconsistent result cache (for example, ArrayCache), or a bug in Dontrine 2.2.2 (although I canβt find anything about it on the dir).
PS: I'm going from another question ( Disabling, Caching, and Merging Doctrine ) that you upgraded to Doctrine 2.3. Do you still have this problem?
PPS: Somewhere after Doctrine 2.0 (I think it was 2.2), the result cache has changed. Instead of caching the hydrated result, the sql result is cached (and hydration occurs every time it starts). If you want to cache a hydrated result, you will have to use a hydration cache (but be careful that these results do not merge into the EntityManager).
source share