• Edit
  • Delete

Doctrine cache

As of sf 1.4

http://www.symfony-project.org/advent_calendar/12/en

 

http://www.doctrine-project.org/documentation/manual2/1_0/en/one-page#caching

http://www.sfblog.fr/page/utiliser-memcache-avec-doctrine-sous-symfony

 

Setup for sf 1.2

 

In the ProjectConfiguration:

  •   public function initialize()
      {
        //enable Doctrine cache
        $manager = Doctrine_Manager::getInstance();
        $cacheDriver = new Doctrine_Cache_Apc();
        $manager->setAttribute(Doctrine::ATTR_RESULT_CACHE, $cacheDriver);
      }

Example query (in UllFlowAppTable.class.php):

  •   /**
       * Find by Id
       *
       * @param integer $id
       * @return Doctrine_Record
       */ 
      public static function findById($id)
      {
        $q = new Doctrine_Query;
        $q
          ->from('UllFlowApp')
          ->where('id = ?', $id)
          ->useResultCache(true)
        ;
       
        return $q->execute()->getFirst();
      }

.