Zend Framework頁面緩衝執行個體_php執行個體

來源:互聯網
上載者:User
一般使用工廠方式:Zend_Cache::factory()的建立緩衝對象。

Zend_Cache::factory方法有四個參數: 前端類型,後端類型,前端參數,後端參數。

以下為頁面緩衝執行個體:

class Zend_Controller_Shawn extends Zend_Controller_Action{    public static $cache;   public function init()  {    $frontendOptions = array(      'lifetime'    => 3600, // 緩衝壽命      'debug_header'  => true, // true是開啟debug,通常設為false      'regexps'     => array(          '^/$'      => array('cache' => true), // 所有頁面都緩衝          '^/index/'    => array('cache' => true), // 緩衝index下所有action頁          '^/index/search' => array('cache' => false), // 對search action不緩衝      ),      'default_options' => array(          'cache_with_get_variables'   => true,          'cache_with_post_variables'   => true,          'make_id_with_cookie_variables' => true, // 注意如果開了session要把這個開啟          'cache_with_session_variables' => true, // 注意如果開了session要把這個開啟          'cache_with_files_variables'  => true,          'cache_with_cookie_variables'  => true, // 注意如果開了session要把這個開啟      )    );     $backendOptions = array('cache_dir' => 'C:/www/zend/cache/'); // 緩衝存放路徑,必須存在並可寫     self::$cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions);     self::$cache->start(); // 開始緩衝         //如有需要,可以再其他頁面進行緩衝清理    Zend_Controller_Shawn::$cache->clean(Zend_Cache::CLEANING_MODE_ALL);   }}


更多細節,可以參考 Zend 官方手冊 http://framework.zend.com/manual/1.12/en/zend.cache.frontends.html

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.