我有沒有辦法使zend_cache對待類似於smarty的前端視圖?我想減少加載時間,頁面緩存似乎是最好的辦法。Zend頁面緩存與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);
}
我希望能捕捉整個看法。
有沒有人有任何如何完全實現它的工作示例?這些文檔並沒有真正深入。