有没有办法让zend_cache处理类似smarty的前端视图?我想减少加载时间,页面缓存似乎是最好的方法。
此外,它还需要类似于{nocache}的内容。
好的,我现在有了: Bootstrap.php
protected function _initCache() {
$this->bootstrap('locale');
$locale = $this->getResource('locale');
$front = array ( 'lifetime' => 1800,
'automatic_serialization' => false,
'caching' => true,
'cache_id_prefix' => 'ec_',
'debug_header' => true,
'default_options'
=> array ('cache_with_get_variables' => true,
'cache_with_post_variables' => false,
'cache_with_session_variables' => false,
'cache_with_cookie_variables' => false ),
);
$back = array('cache_dir' => '../data/Cache/'.$locale);
$cache = Zend_Cache::factory('Page', 'File', $front, $back);
$cache->start();
Zend_Registry::set('cache', $cache);
return $cache;
}然而,我的缓存被命中的唯一一次是使用如下代码:
$cache = Zend_Registry::get('cache');
if (!$data = $cache->load('sidebar_'.$module.'_'.$controller)) {
$data['Studio'] = Eurocreme_Studio::load_by_type(array('type' => 'sidebar', 'from' => 0, 'to' => COUNT_HIGH));
$data['Movie'] = Eurocreme_Movie::load_by_type(array('type' => 'sidebar', 'from' => 0, 'to' => 5));
$data['Gallery'] = Eurocreme_Gallery::load_by_type(array('type' => 'sidebar', 'from' => 0, 'to' => 5));
$data['Category'] = Eurocreme_Category::load_tree(0);
$cache->save($data, 'my_view_helper_sidebar_'.$module.'_'.$controller);
}我希望能捕捉到整个场景。
有没有人有任何实际的例子来说明如何完全实现它?这些文档并不是很深入。
发布于 2010-03-14 22:26:56
您可能希望使用Zend_Cache_Frontend_Output或Zend_Cache_Frontend_Page。来自Zend Framework manual
Zend_Cache_Frontend_Output是一个捕获输出的前端。它利用PHP中的输出缓冲来捕获start()和end()方法之间的所有内容。
Zend_Cache_Frontend_Page类似于Zend_Cache_Frontend_Output,但它是为完整的页面而设计的。
发布于 2010-03-14 22:28:53
您可能正在寻找Zend_Cache_Frontend_Page。详情请参考Zend Cache docs。
https://stackoverflow.com/questions/2442171
复制相似问题