当同时使用mencache和缓存页面时,使用zend框架



我使用的是zend frameword版本1.11

我的网站使用memcache来保存会话,但希望使用更多的zend缓存页面来缓存页面html

结果:缓存页面html是未保存正确的缓存目录配置,它保存公共路径并且文件中的数据为空(0 KB)

做兄弟帮助

application.ini中的我的配置

; MEMCACHE CONFIG
resources.cachemanager.memcached.frontend.name                            = Core
resources.cachemanager.memcached.frontend.options.automatic_serialization = On
resources.cachemanager.memcached.backend.name                             = Memcached
resources.cachemanager.memcached.backend.options.servers.one.host         = 10.60.80.51
resources.cachemanager.memcached.backend.options.servers.one.port         = 11211
resources.cachemanager.memcached.backend.options.servers.one.persistent   = On
; session savehandler class
resources.session.name = PHPGAME1_SESSION
resources.session.saveHandler.class        = Zend_Session_SaveHandler_Cache
resources.session.gc_maxlifetime           = 7200
resources.session.cookie_domain            = ".game5.vn"
;cofig cache page
resources.cacheManager.page.backend.options.public_dir = PUBLIC_PATH "/cached"
resources.cacheManager.pagetag.backend.options.cache_dir = WEB_PATH "/data/cache/tags"
resources.frontController.params.disableOutputBuffering = true
resources.cacheManager.page.backend.options.disable_caching = false

我的引导程序到初始化会话处理程序

protected function _initSessionId()
{
    $opts = $this->getOptions();
    if (isset($opts['resources']['session']['saveHandler']['class']) &&
            'Zend_Session_SaveHandler_Cache' == $opts['resources']['session']['saveHandler']['class']) {
        $this->bootstrap('session');
        $cache = $this->bootstrap('cachemanager')
        ->getResource('cachemanager')
        ->getCache('memcached');
        Zend_Session::getSaveHandler()->setCache($cache);
    }                     
    $defaultNamespace = new Zend_Session_Namespace();
    if (!isset($defaultNamespace->initialized)) {
        Zend_Session::regenerateId();
        $defaultNamespace->initialized = true;
    }
}

在init controller中,我使用helper来保存缓存页面,这个操作需要保存缓存页面

$this->_helper->cache(array('index'), array('content'));

非常感谢

已解析

我在配置中有两个片段:cachemanager和cachemanager,当组合时,zend-cache只得到第一个片段(cachemanager)

配置成功:

; CACHE CONFIG
resources.cachemanager.memcached.frontend.name                            = Core
resources.cachemanager.memcached.frontend.options.automatic_serialization = On
resources.cachemanager.memcached.backend.name                             = Memcached
resources.cachemanager.memcached.backend.options.servers.one.host         = 127.0.0.1
resources.cachemanager.memcached.backend.options.servers.one.port         = 11211
resources.cachemanager.memcached.backend.options.servers.one.persistent   = On
; session savehandler class
resources.session.name = PHPGAME5_SESSION
resources.session.saveHandler.class        = Zend_Session_SaveHandler_Cache
resources.session.gc_maxlifetime           = 7200
resources.session.cookie_domain            = ".game5.vn"

; CACHE CONFIG
resources.cachemanager.page.backend.options.public_dir = PUBLIC_PATH "/cached"
resources.cachemanager.pagetag.backend.options.cache_dir = WEB_PATH "/data/cache/tags"
resources.frontController.params.disableOutputBuffering = true
resources.cachemanager.page.backend.options.disable_caching = false
resources.cachemanager.page.backend.options.cache_directory_umask = 0775
resources.cachemanager.page.backend.options.cache_file_umask  = 0775

相关内容

  • 没有找到相关文章

最新更新