【问题标题】:Use PHP memcache in yii2在yii2中使用PHP memcache
【发布时间】:2017-04-04 16:57:05
【问题描述】:

yii2我需要使用我已经安装的memcache插件,这也会显示在phpinfo中,但是运行项目时出现以下错误:

无效配置 - yii\base\InvalidConfigException - MemCache 需要加载 PHP memcache 扩展。

缓存配置

'cache' => [ 
       'class' => 'yii\caching\MemCache', 
       'servers' => [ 
           [ 
               'host' => '127.0.0.1', 
               'port' => 11211, 
               'weight' => 60, 
           ], 
       ], 
]

【问题讨论】:

  • 显示你的缓存配置。
  • 'cache' => [ 'class' => 'yii\caching\MemCache', 'servers' => [ [ 'host' => '127.0.0.1', 'port' => 11211, '重量' => 60, ], ], ],
  • 您使用的是Memcache 还是Memcached
  • 我在我的操作系统(windows 10)上安装了 memcached
  • @AliMoradi :所以卸载它并安装Memcache。一切正常

标签: php caching yii2 memcached


【解决方案1】:

也许您使用的是 memcached 而不是 memcache。这种情况下的配置应该是:

'cache' => [
    'class' => 'yii\caching\MemCache',
    'useMemcached' => true, // <--- here
    'servers' => [
        [
            'host' => '127.0.0.1',
            'port' => 11211,
            'weight' => 60,
        ],
    ],
],

【讨论】:

  • 做但没有区别
  • 是在控制台还是web应用中使用?
  • 网络应用程序
  • 你能显示带有 phpinfo 的屏幕截图并提到它已安装吗?
  • 仔细检查您的php.ini 中是否有未注释的php_memcache.dll(或类似)条目
猜你喜欢
  • 1970-01-01
  • 2011-06-14
  • 2020-03-16
  • 2017-02-17
  • 2015-07-20
  • 1970-01-01
  • 1970-01-01
  • 2015-08-29
  • 2012-01-19
相关资源
最近更新 更多