views:

54

answers:

1

I'm using Doctrine 1.2 with Zend Framework, and it's working just fine. Now I want to start using the results cache and query caching capabilities to reduce the load on DB server that powers the application. Oh, I'm also using Zend_Application and placing code in modules.

Anyway, I setup my connections to Doctrine in the overall Bootstrap.php file for the application itself:

protected function _initDoctrine()  
{  
    Zend_Loader_Autoloader::getInstance()->registerNamespace('Doctrine')->pushAutoloader(array('Doctrine', 'autoload'));  

    $manager = Doctrine_Manager::getInstance();  

    foreach ($this->_options['doctrine']['attr'] as $key => $val) {  
        $manager->setAttribute(constant("Doctrine::$key"), $val);  
    }  

    $conn = Doctrine_Manager::connection($this->_options['doctrine']['dsn'], 'doctrine');  

    Doctrine::loadModels($this->_options["doctrine"]["module_directories"]);  
}

Now, I spent some time reading both the documentation for query and result caching for Doctrine and looking for examples of using Doctrine's caching. What I found appears to be very straightforward. I added this code to the Bootstrap.php file that contains the _initDoctrine() method, inside _initDoctrine()

    // Set up some caching
    $cacheConn = Doctrine_Manager::connection(new PDO('sqlite::memory:'));
    $cacheDriver = new Doctrine_Cache_Db(array(
        'connection' => $cacheConn,
        'tableName' => 'cache'));
    $cacheDriver->createTable();
    $manager->setAttribute(Doctrine_Core::ATTR_QUERY_CACHE, $cacheDriver);

What I am now finding happening is that the entire connection for the application now thinks it is using Sqlite instead of MySQL like it is supposed to. Which seems odd, since I am only setting the ATTR_QUERY_CACHE attribute.

Tips on resolving this would be greatly appreciated.

A: 

Decided to go with APC as the backend instead of SQLite, based on feedback from Twitter.

GrumpyCanuck