2016-11-21 80 views
0

yii2我需要使用內存緩存插件我已經安裝了,這也將顯示在的phpinfo但在運行項目時,我得到了以下錯誤:使用PHP的memcache在yii2

無效的配置 - 警予\基地\ InvalidConfigException - MemCache需要加載PHP memcache擴展。

enter image description here

緩存配置

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

顯示您的緩存配置。 – Bizley

+0

'緩存'=> [ '類'=> 'YII \緩存\ MEMCACHE', '服務器'=> [ [ '主機'=> '127.0.0.1', '端口'=> 11211, 'weight'=> 60, ], ], ], –

+0

您使用的是Memcache還是Memcached? – smoqadam

回答

0

也許你已經得到了memcached的,而不是內存緩存。在這種情況下的配置應該是:

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

做到這一點,但沒有差別 –

+0

它在控制檯或Web應用程序中使用嗎? – Bizley

+0

網絡應用程序 –