我正在使用zend frameword version 1.11
我的网站使用memcache保存会话但希望使用更多的zend缓存页面来缓存页面html
结果:缓存页面html 不保存正确缓存dir配置,它保存公共路径,文件中的数据为空(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
我的initrap到init会话处理程序
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控制器中,我使用helper来保存缓存页面,需要保存缓存页面的操作
$this->_helper->cache(array('index'), array('content'));
非常感谢
答案 0 :(得分:1)
解决
我在config中有2个段: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