【问题标题】:Zend Cache Front endZend 缓存前端
【发布时间】:2013-06-18 20:53:38
【问题描述】:

我在Bootstrap.php中使用这个函数来缓存我的控制器,我只需要缓存一些控制器我不需要缓存索引控制器和文章控制器为例 我需要缓存问题控制器,但它不起作用。这个函数缓存了我所有的控制器

protected function _initCache()
{
    mb_internal_encoding("UTF-8");
    $dir = "/var/www/data/cache/all";

   $frontendOptions = array(
        'lifetime' => 3600,
        'content_type_memorization' => true,
        'default_options'           => array(
        'cache' => true,
        'cache_with_get_variables' => true,
        'cache_with_post_variables' => true,
        'cache_with_session_variables' => true,
        'cache_with_cookie_variables' => true,
        ),
    'regexps' => array(

             '^/$' => array('cache' => false),
            "^/question/" => array('cache' => true),
            "^/article/" => array('cache' => false),
             )
    );
    $backendOptions = array(
            'cache_dir' =>$dir
    );

    // getting a Zend_Cache_Frontend_Page object
    $cache = Zend_Cache::factory('Page',
                         'File',
                         $frontendOptions,
                         $backendOptions);

    $cache->start();
}

所以我能做什么我尝试了所有解决方案,请帮助我。 谢谢

【问题讨论】:

    标签: php zend-framework zend-cache


    【解决方案1】:

    使用该代码创建一个控制器插件,并检测请求。 比如……

    if($request->getControllerName() == 'index' || ... == 'article') {
    return;
    }
    mb_internal_encoding("UTF-8");
    ...
    

    【讨论】:

    • 谢谢我做了类似你的解决方案的事情,但是在我的 Bootstrap 函数中使用 $request = $_SERVER['REQUEST_URI']; if ($request == 'artice') { /* 我的缓存功能*/ } 非常感谢
    猜你喜欢
    • 1970-01-01
    • 2014-04-30
    • 2012-03-10
    • 2013-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多