我正在使用 Zend_Session_SaveHandler_DbTable 将会话存储在表中
我的分析器告诉我,在每个页面请求上,zend 都会:
# 查询时间
(1)连接0.0032038688659668
(2) 描述session
0.0041539669036865
(3) SELECT session
.* FROM session
WHERE ((( session
. session_id
= '7nnan8ltd6h64sigs6dlkicvh0' AND session
. save_path
= '' AND session
. name
= 'PHPSESSID'))) 0.00057697296142578
总时间:0.008 秒
当我对其他表进行查询时,zend 对它们进行一次 DESCRIBE(它第一次访问该表时),然后如果我刷新页面它只进行没有描述的查询,在会话表上它会在每个页面上进行 DESCRIBE(因为我使用身份验证...)
我怎样才能只缓存会话表上的元数据?
我目前正在使用这个
class Gestionale_Application_Resource_Cache extends Zend_Application_Resource_ResourceAbstract{
public function init ()
{
$options = $this->getOptions();
// Get a Zend_Cache_Core object
//valori che vengono presi dal file di configurazione
$cache = Zend_Cache::factory(
$options['frontEnd'],
$options['backEnd'],
$options['frontEndOptions'],
$options['backEndOptions']);
Zend_Registry::set('cache', $cache);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);//per mettere in cache la meta-info
return $cache;
}
这是我的配置文件
...
;cache stuff
resources.cache.frontEnd = core
resources.cache.backEnd = file
resources.cache.frontEndOptions.lifetime = 1200 ; in secondi
resources.cache.frontEndOptions.automatic_serialization = true
resources.cache.backEndOptions.lifetime = 3600 ; in secondi
resources.cache.backEndOptions.cache_dir = APPLICATION_PATH "/../cache"
pluginPaths.Gestionale_Application_Resource = APPLICATION_PATH "/../library/Gestionale/Application/Resource"
;;fine cache stuff
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.db.params.charset = "utf8"
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "gestionale"
resources.db.isDefaultTableAdapter = true
autoloaderNamespaces[] = "Gestionale_";serve per caricare il plugin di sotto quando si usa anche ZFdebug
resources.frontController.plugins.acl = "Gestionale_Controller_Plugin_Acl"
resources.db.params.profiler = true
...
这是我的会话表
CREATE TABLE IF NOT EXISTS `session` (
`session_id` char(32) NOT NULL,
`save_path` varchar(32) NOT NULL,
`name` varchar(32) NOT NULL DEFAULT '',
`modified` int(11) DEFAULT NULL,
`lifetime` int(11) DEFAULT NULL,
`session_data` text,
PRIMARY KEY (`session_id`,`save_path`,`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
感谢:D