我在Zend Framework中使用Doctrine 1.2,它工作得很好。现在我想开始使用结果缓存和查询缓存功能来减少为应用程序提供动力的数据库服务器上的负载。哦,我也在使用Zend_Application并将代码放在模块中。Zend Framework,Doctrine和缓存问题
反正我设置在应用程序本身整体的bootstrap.php文件我的教义连接:
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"]);
}
现在,我花了一些时间阅读这两个查询和结果缓存的文档主义和寻找使用Doctrine的缓存的例子。我发现的东西看起来非常简单。我将此代码添加到的bootstrap.php文件,其中包含_initDoctrine()方法,里面_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);
什么,我现在发现情况是,应用程序的整个连接现在认为它改为使用SQLite的MySQL像它应该的。这似乎很奇怪,因为我只设置了ATTR_QUERY_CACHE属性。
解决此问题的提示将不胜感激。