我正在尝试让memcache与Zendframework 2一起工作。如何让Zendframework 2看到memcache正确,所以我没有得到下面列出的错误?我想使用memcache而不是memcached。
错误:
Exception - An abstract factory could not create an instance of memcache(alias: memcache).
Previous exceptions - An exception was raised while creating "memcache"; no instance returned
The option "liboptions" does not have a matching setLiboptions setter method which must be defined
在尝试使用控制器中的此行测试时出现此错误
echo $this->getServiceLocator()->get('memcache')->getVersion();
详细信息:
我正在运行Windows 7 64位,并启动并运行IIS7的本地实例。
我使用本指南在我的电脑上安装memecache:How to Install Memcache on Windows 7
我验证了memcache服务已启动并正在运行 我验证了在Zendframework 2之外使用memecache。
接下来我按照本指南在Zendframework 2中使用它:How to setup Zendframework 2 to use Memcached我知道这个指南适用于memcached而不是memcache但我用它作为基础
我已经完成的故障排除:
代码:
config var_dump显示抽象工厂部分正在加载
$sm = $this->getServiceLocator();
$config = $sm->get('config');
var_dump($config);die();
'service_manager' =>
array (size=3)
'abstract_factories' =>
array (size=2)
0 => string 'Zend\Cache\Service\StorageCacheAbstractServiceFactory' (length=53)
1 => string 'Zend\Log\LoggerAbstractServiceFactory' (length=37)
'aliases' =>
array (size=2)
'translator' => string 'MvcTranslator' (length=13)
'db' => string 'Zend\Db\Adapter\Adapter' (length=23)
'factories' =>
array (size=1)
'Zend\Db\Adapter\Adapter' => string 'Zend\Db\Adapter\AdapterServiceFactory' (length=37)
我的cache.local.php和它在zendframework 2的自动加载目录中(取自上面的教程链接并删除了' d') 我认为这是我需要改变的,只是不确定如何......
return array(
'caches' => array(
'memcache' => array( //can be called directly via SM in the name of 'memcache'
'adapter' => array(
'name' =>'memcache',
'lifetime' => 86400, //24 hours
'options' => array(
'servers' => array(
array(
'127.0.0.1',11211 //Server IP, Port
)
),
'namespace' => 'MYMEMCACHENAMESPACE',
'liboptions' => array (
'COMPRESSION' => true,
'binary_protocol' => true,
'no_block' => true,
'connect_timeout' => 120
)
)
),
'plugins' => array(
'exception_handler' => array(
'throw_exceptions' => false
),
),
),
),
);