Zend Framework頁面緩存實(shí)例
一般使用工廠方式:Zend_Cache::factory()的創(chuàng)建緩存對(duì)象。
Zend_Cache::factory方法有四個(gè)參數(shù): 前端類型,后端類型,前端參數(shù),后端參數(shù)。
以下為頁面緩存實(shí)例:
class Zend_Controller_Shawn extends Zend_Controller_Action { public static $cache; public function init() { $frontendOptions = array( 'lifetime' => 3600, // 緩存壽命 'debug_header' => true, // true是打開debug,通常設(shè)為false 'regexps' => array( '^/$' => array('cache' => true), // 所有頁面都緩存 '^/index/' => array('cache' => true), // 緩存index下所有action頁 '^/index/search' => array('cache' => false), // 對(duì)search action不緩存 ), 'default_options' => array( 'cache_with_get_variables' => true, 'cache_with_post_variables' => true, 'make_id_with_cookie_variables' => true, // 注意如果開了session要把這個(gè)打開 'cache_with_session_variables' => true, // 注意如果開了session要把這個(gè)打開 'cache_with_files_variables' => true, 'cache_with_cookie_variables' => true, // 注意如果開了session要把這個(gè)打開 ) ); $backendOptions = array('cache_dir' => 'C:/www/zend/cache/'); // 緩存存放路徑,必須存在并可寫 self::$cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions); self::$cache->start(); // 開始緩存 //如有需要,可以再其他頁面進(jìn)行緩存清理 Zend_Controller_Shawn::$cache->clean(Zend_Cache::CLEANING_MODE_ALL); } }
更多細(xì)節(jié),可以參考 Zend 官方手冊(cè) http://framework.zend.com/manual/1.12/en/zend.cache.frontends.html
- windows下zendframework項(xiàng)目環(huán)境搭建(通過命令行配置)
- Zend Framework數(shù)據(jù)庫操作技巧總結(jié)
- Zend Framework數(shù)據(jù)庫操作方法實(shí)例總結(jié)
- Zend Framework入門應(yīng)用實(shí)例詳解
- Zend Framework入門教程之Zend_View組件用法示例
- Zend Framework開發(fā)入門經(jīng)典教程
- 解析zend Framework如何自動(dòng)加載類
- Zend Framework 2.0事件管理器(The EventManager)入門教程
- Zend Framework+smarty用法實(shí)例詳解
- Zend Framework入門知識(shí)點(diǎn)小結(jié)
- Zend Framework緩存Cache用法簡單實(shí)例
- Zend?Framework基于Command命令行建立Zend?Framework項(xiàng)目的方法
相關(guān)文章
php獲取小程序碼的實(shí)現(xiàn)代碼(B類接口)
這篇文章主要介紹了php獲取小程序碼的實(shí)現(xiàn)代碼(B類接口),需要的朋友可以參考下2020-06-06PHP錯(cuò)誤Allowed memory size of 67108864 bytes exhausted的3種解決辦法
這篇文章主要介紹了PHP錯(cuò)誤Allowed memory size of 67108864 bytes exhausted的3種解決辦法,PHP的內(nèi)存溢出錯(cuò)誤,需要的朋友可以參考下2014-07-07phpStudy2016 配置多個(gè)域名期間遇到的問題小結(jié)
這篇文章主要介紹了phpStudy2016 配置多個(gè)域名期間遇到的問題小結(jié),需要的朋友可以參考下2017-10-10yii2.0數(shù)據(jù)庫遷移教程【多個(gè)數(shù)據(jù)庫同時(shí)同步數(shù)據(jù)】
這篇文章主要介紹了yii2.0數(shù)據(jù)庫遷移的方法,可實(shí)現(xiàn)多個(gè)數(shù)據(jù)庫同時(shí)同步數(shù)據(jù)的功能,較為詳細(xì)的分析了Yii2針對(duì)遷移的創(chuàng)建、提交、重做及自定義遷移的相關(guān)概念與使用方法,需要的朋友可以參考下2016-10-10