我安装了memcached。这来自phpinfo():
但像这样使用它时:
private static function getZendCacheMemcachedObject()
{
$frontendOpts = array(
'caching' => true,
'lifetime' => 3600,
'automatic_serialization' => true
);
$backendOpts = array(
'servers' =>array(
array(
'host' => 'localhost',
'port' => 11211,
'weight' => 1
)
),
'compression' => false
);
return Zend_Cache::factory('Core', 'Memcached', $frontendOpts, $backendOpts);
}
public function foo($id)
{
$cache = self::getZendCacheMemcachedObject();
$cacheKey = 'foo_'.$id;
$xml = $cache->load($cacheKey);
if (false === $xml) {
$xml = $this->httpClient->foo();
$cache->save($xml, $cacheKey);
}
return $xml;
}
我得到了这个错误:
The memcache extension must be loaded for using this backend
有什么想法吗?
发布于 2013-08-22 02:09:09
对于您已经安装的PHP库,最简单的解决方案似乎是使用不同的后端-如果您的zend框架版本允许:
Zend_Cache_Backend_Libmemcached (http://doczf.mikaelkael.fr/1.11/en/zend.cache.backends.html)
我假设return Zend_Cache::factory('Core','Memcached',$frontendOpts,$backendOpts);变成return Zend_Cache::factory('Core','Libmemcached',$frontendOpts,$backendOpts);
发布于 2014-08-21 12:25:52
我解决这个问题很简单。发生这个问题是因为你没有安装php memcached扩展。让我们在Ubuntu中通过这个命令安装它。
sudo apt-get install php-memcached
或者在其他操作系统中,您可以自己搞清楚
https://stackoverflow.com/questions/9790780
复制相似问题