我正在尝试在 zend Framework 2 中启用配置文件的缓存:
module.config.php(服务的一部分):
'service_manager' => array(
'factories' => array(
'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
'doctrine.cache.mycache' => function ($sm) {
$cache = new \Doctrine\Common\Cache\MemcacheCache();
$memcache = new \Memcache();
$memcache->connect('localhost', 11211);
$cache->setMemcache($memcache);
return $cache;
},
),
),
application.config.php(启用配置缓存的一部分):
'module_listener_options' => array(
'module_paths' => array(
'./module',
'./vendor',
),
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
),
'config_cache_enabled' => true,
'config_cache_key' => md5('config'),
'module_map_cache_enabled' => true,
'module_map_cache_key' => md5('module_map'),
'cache_dir' => "./data/cache/modulecache",
),
这是我得到的错误:
Fatal error: Call to undefined method Closure::__set_state()
谢谢。
最佳答案
如果配置文件包含匿名函数(在您的情况下为 doctrine.cache.mycache
的值),则无法缓存它们。您需要将该部分从配置文件中移出并移入您的 Module.php
类的 getServiceConfig()
中。这应该可以解决问题。
关于php - zend Framework 2 - 缓存配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27251931/