In doctrine
to cache queries or results you can do the following:
private function myQuery()
{
return $this->connect->createQueryBuilder()
->select('user_id')
->from('users', 'u')
->where('u.user_id = 2')
->getQuery()
->useQueryCache(true) // here
->useResultCache(true); // and here
}
Check doc for more info about these methods. This will make your
cache driver working - doesn't matter what driver you are using.
To configure Symfony
to use specific query driver you need to adjust your settings in config.yml
- check this to see complete list of options. What is important in your cache is (this is apc
configuration example):
entity_managers:
some_em:
query_cache_driver: apc
metadata_cache_driver: apc
result_cache_driver: apc
You might also want to check this and this blog entries