我正在尝试优化zend的性能。
我使用了尽可能多的缓存并得到了这个page的代码
我在哪里写它?我尝试将它放在bootstrap __initAutoload()
中,但是探查器显示没有任何改变
$classFileIncCache = APPLICATION_PATH . '/../data/pluginLoaderCache.php';
if (file_exists($classFileIncCache)) {
include_once $classFileIncCache;
}
Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
有人可以解释一下如何使用pluginloader以及它是否有性能提升?
这是我的引导程序的一部分
protected function _initSessionAfterDb()
{
//http://stackoverflow.com/questions/1100562/zend-error-via-my-ini-file
$this->bootstrap('db');
$this->bootstrap('session');
}
protected function _initSession()
{
$this->bootstrap('cache');//http://stackoverflow.com/questions/5271018/zend-how-to-enable-cachemetadata-on-session-table
//NOTE: this config is also passed to Zend_Db_Table so anything specific
//to the table can be put in the config as well
$config = array(
'name' => 'session', //table name as per Zend_Db_Table
'primary' => array(
'session_id', //the sessionID given by PHP
'save_path', //session.save_path
'name', //session name
//'cols' => array('session_id', 'save_path', 'name', 'modified', 'lifetime', 'session_data')
),
'primaryAssignment' => array(
//you must tell the save handler which columns you
//are using as the primary key. ORDER IS IMPORTANT
'sessionId', //first column of the primary key is of the sessionID
'sessionSavePath', //second column of the primary key is the save path
'sessionName', //third column of the primary key is the session name
),
'modifiedColumn' => 'modified', //time the session should expire
'dataColumn' => 'session_data', //serialized data
'lifetimeColumn' => 'lifetime', //end of life for a specific record
'user_id' => 'user_id'
);
//Tell Zend_Session to use your Save Handler
$savehandler = new Zend_Session_SaveHandler_DbTable($config);
//http://framework.zend.com/wiki/display/ZFPROP/Zend_Session_SaveHandler_DbTable
//cookie persist for 30 min
$config = Zend_Registry::get('config');
$seconds = $config->session->seconds_life;
//make the session persist for 30 min
$savehandler->setLifetime($seconds)
->setOverrideLifetime(true);
Zend_Session::setSaveHandler($savehandler);
Zend_Session::start();
}
答案 0 :(得分:0)
我认为你并没有从良好的脚开始,早期优化是所有邪恶的根源。首先,我认为您应该调查应用程序的哪个部分是最慢的并尝试修复它,xdebug应该能够帮助获取一些性能数据。
插件加载器缓存会提高性能,但不是很大,框架搜索文件系统中正在使用的插件。启用缓存会跳过搜索过程,但我怀疑它会使您的应用程序全部速度提高50%。
还要回答你应该写它的地方,就像你提到的引导可能是最好的地方。