gpt4 book ai didi

php - 必须加载内存缓存扩展才能使用此后端

转载 作者:IT王子 更新时间:2023-10-29 00:01:04 24 4
gpt4 key购买 nike

我安装了 memcached。这是来自 phpinfo():

enter image description here

但是这样使用时:

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

有什么想法吗?

最佳答案

PHP 有两个名字容易混淆的 Memcached 库:

您的代码需要第一个。只需执行一个简单的 pecl uninstall memcached 然后 pecl install memcache,修改您的 php.ini 以包含适当的 .so,它应该可以工作。

关于php - 必须加载内存缓存扩展才能使用此后端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9790780/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com