How to set memcached options in Yii2?

Hi,

I’m trying to set a Memcached option (disable compression) in the config file, but Yii2 keeps throwing an error. What am I doing wrong?

Here is the config:


'cache' => [

	/* 'class' => 'yii\caching\FileCache', */

	'class' => 'yii\caching\MemCache',

	'servers' => [

		[

			'host' => 'localhost',

			'port' => 11211,

		],

	],

	'useMemcached' => true,

	'serializer' => false,

	'options' => [

		'Memcached::OPT_COMPRESSION' => false,

	],

],

And the error:

‘yii\base\ErrorException’ with message ‘Memcached::setOptions(): invalid configuration option’

Any ideas?

If I do the same thing in plain PHP, it works just fine:


$memcache = new \Memcached;

$memcache->setOption(\Memcached::OPT_COMPRESSION, false);

$memcache->addServers(

	array(

		array("HOST" => "127.0.0.1", "PORT" => 11211),

	)

);

Try




'options' => [

                \Memcached::OPT_COMPRESSION => false,

        ],




That worked perfectly. Thank you!