Using Memcached with Symfony 1.2 and Doctrine
September 15th, 2009
Make sure you have Memcached installed.
Add this to ProjectConfiguration.class.php
//ProjectConfiguration.class.php public function configureDoctrine(Doctrine_Manager $manager) { $servers = array( 'host' => 'localhost', 'port' => 11211, 'persistent' => true ); $cacheDriver = new Doctrine_Cache_Memcache(array( 'servers' => $servers, 'compression' => false ) ); //enable Doctrine cache $manager = Doctrine_Manager::getInstance(); $manager->setAttribute(Doctrine::ATTR_RESULT_CACHE, $cacheDriver); }
Add this to your query
->useResultCache(true);
How does Doctrine know if the cache has expired or do you have to manage that at the application level in Symfony?
Many thanks
Ben,
You could use
There is much more info about caching in doctrine here:
http://www.doctrine-project.org/documentation/manual/1_1/en/caching
Many thanks