必须加载 memcache 扩展才能使用此后端
2022-08-30 19:43:15
我安装了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
有什么想法吗?