Memcached Configuration in CakePHP 3x


#1

I am a previous CakePHP 2 user and am starting a new application using CakePHP3, I have searched but am finding very little examples and/or detailed instructions on the configuration of Memcached for my application.

In CakePHP 2 I simply created a Cache configuration like:

Cache::config(‘5m’, array(
‘engine’ => ‘Memcached’,
‘duration’ => 3600,
‘servers’ => array(‘127.0.0.1:11211’)));

I am unable to find an example that is equivalent to this for CakePHP 3. I have tried using:

‘Cache’ => [
‘5m’ => [
‘className’ => ‘Memcached’,
‘duration’ => ‘+5 minutes’,
‘servers’ => ‘127.0.0.1:11211’
],

However I receive “Cache engine Cake\Cache\Engine\MemcachedEngine is not properly configured.” error which tells me almost nothing on what needs to be adjusted. I am sure this is a simple configuration / syntax issue on my part, however, I am unable to find a full working example or description on how to get memcached usable in CakePHP 3.

  • I know Memcached is installed correctly and running as all of my CakePHP 2 applications are using it just fine.

  • I’d prefer to not use the DSN format.

Any help is appreciated.


#2

The config i use is:

'flags' => [
    'className' => 'Cake\Cache\Engine\MemcachedEngine',
    'prefix' => 'flags_data_',
    'path' => CACHE . 'flags/',
    'duration' => '+10 seconds'
]

Hope it helps you.


#3

I have the same issue with cakephp 3, error in “ Cache engine Cake\Cache\Engine\MemcachedEngine is not properly configured. ”.

Cache::config(‘long’, [
‘className’ => ‘Cake\Cache\Engine\MemcachedEngine’,
‘prefix’ => ‘flags_data_’,
‘path’ => CACHE . ‘flags/’,
‘duration’ => ‘+10 seconds’
]);

This settings not working for me. any help?