How to install memcached in Yii2?

I am trying to set the Memcached parameter (disable compression) in the configuration file, but Yii2 continues to throw an error. What am I doing wrong?

Here is the configuration:

'cache' => [
    /* 'class' => 'yii\caching\FileCache', */
    'class' => 'yii\caching\MemCache',
    'servers' => [
        [
            'host' => 'localhost',
            'port' => 11211,
        ],
    ],
    'useMemcached' => true,
    'serializer' => false,
    'options' => [
        'Memcached::OPT_COMPRESSION' => false,
    ],
],

And error: 'yii \ base \ ErrorException' with the message 'Memcached :: setOptions (): wrong configuration setting

Any ideas?

If I do the same in simple PHP, it works fine:

$memcache = new \Memcached;
$memcache->setOption(\Memcached::OPT_COMPRESSION, false);
$memcache->addServers(
    array(
        array("HOST" => "127.0.0.1", "PORT" => 11211),
    )
);
+4
source share
1 answer

try it

'options' => [
    \Memcached::OPT_COMPRESSION => false,
],
+4
source

Source: https://habr.com/ru/post/1606846/


All Articles