簡體   English   中英

在yii2中使用PHP內存緩存

[英]Use PHP memcache in yii2

yii2我需要使用memcache插件,我已經安裝了該插件,它也會顯示在phpinfo中,但是在運行項目時出現以下錯誤:

無效的配置– yii \\ base \\ InvalidConfigException-MemCache需要加載PHP memcache擴展。

在此處輸入圖片說明

緩存配置

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

也許您有memcached而不是memcache。 在這種情況下,配置應為:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM