zend-frameworkmemcachedzend-cache

zend framework when using both mencache and cache page


I'm using zend frameword version 1.11

My site using memcache to save session but want using more zend cache page to cache page html

Result: cache page html is not save right cache dir config, it save public path and data in file is null (0 KB)

To be bro help

my config in 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

My boostrap to init session handler

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;
    }
}

In init controller, i have using helper to save cache page, action which want save cache page

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

Many thanks


Solution

  • Resolved

    I have 2 segment in config: cachemanager and cacheManager, when combining, zend cache only get first segment (cachemanager)

    Config success:

    ; 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