gpt4 book ai didi

zend-framework - 从 zend3 更新到 PHP 8.1 后的 Laminas 缓存配置问题

转载 作者:行者123 更新时间:2023-12-05 08:03:41 25 4
gpt4 key购买 nike

我从事的项目最近从 Zend3 和 PHP 7.4 更新到 Laminas 和 PHP 8.1。

在 config/autoload/global.php 中

  'caches' => require __DIR__ . '/caches.php',

这是 caches.php

$cacheDefault = [
'adapter' => [
'name' => 'Memcached',
'options' => [
'servers' => Module::isRunningOnVM()
? ['127.0.0.1:11211']
: Module::getMemcachedServersFromEnvironment(),
],
],
];

return [

'cache_instrument_manager_search' => array_merge_recursive(
$cacheDefault,
[
'adapter' => [
'options' => [
'namespace' => 'instrument_manager_search',
'ttl' => 20,
],
],
]
),

'cache_weekly' => array_merge_recursive(
$cacheDefault,
[
'adapter' => [
'options' => [
'namespace' => 'weekly',
'ttl' => 604800, // whole week
],
],
]
),
];

它在 zend 3 中运行良好。但是在更新到 Laminas 和 PHP8.1 后我得到了这个错误

Laminas\ServiceManager\Exception\ServiceNotCreatedException

文件:

/project/vendor/laminas/laminas-servicemanager/src/ServiceManager.php:620

留言:

Service with name "cache_instrument_manager_search" could not be created. Reason: Configuration must contain a "adapter" key.

我改成了

return [

'cache_instrument_manager_search' => [
'adapter' => 'Memcached',
'options' => ['ttl' => 3600],
'plugins' => [
[
'name' => 'exception_handler',
'options' => [
'throw_exceptions' => false,
],
],
],
]
];

但是还是有这个错误Laminas\ServiceManager\Exception\ServiceNotFoundException

文件:

/project/vendor/laminas/laminas-servicemanager/src/ServiceManager.php:557

留言:

Unable to resolve service "Memcached" to a factory; are you certain you provided it during configuration?

我需要帮助。看了Laminas的文档还是没能解决。

最佳答案

我正在使用 Redis 缓存,我必须添加:

'Laminas\Cache\Storage\Adapter\Redis'

到我的 modules.config.php 文件

关于zend-framework - 从 zend3 更新到 PHP 8.1 后的 Laminas 缓存配置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71396980/

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