Setting up Cakephp & memcache

  • Posted September 15, 2014

Hi guys,

I am trying to setup memcache in Cakephp (2.5.3) on ubuntu 14.

Here’s what I have done :

  1. Setup memcache (based on this ). All is working fine (info.php, grep, service is running, etc).

  2. Update cakephp ‘bootstrap.php’. Change

// Cache::config('default', array('engine' => 'File'));
Cache::config('default', array('engine' => 'Memcache'));

When i load my cakephp page, this error appears :

Cache engine default is not properly configured.

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I tried to change it to ‘memcached’ in bootstrap.php

Cache::config('default', array('engine' => 'Memcached'));

Error :

Cache engine default is not available.

After that, I update core.php with this configuration below but got a fatal error.

Cache::config('default', array(
		'engine' => 'Memcached', //[required]
		'duration' => 3600, //[optional]
		'probability' => 100, //[optional]
 		'prefix' => Inflector::slug(APP_DIR) . '_', //[optional]  prefix every cache file with this string
 		'servers' => array(
 			'' // localhost, default port 11211
 		), //[optional]
 		'persistent' => 'my_connection', // [optional] The name of the persistent connection.
 		'compress' => false, // [optional] compress data in Memcached (slower, but uses less memory)

Error :

Fatal error: Uncaught exception 'CacheException' with message 'Cache engine default is not available.' in /var/www/html/my/lib/Cake/Cache/Cache.php:173 Stack trace: #0 /var/www/html/my/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('default') #1 /var/www/html/my/app/Config/core.php(410): Cache::config('default', Array) #2 /var/www/html/my/lib/Cake/Core/Configure.php(72): include('/var/www/html/m...') #3 /var/www/html/my/lib/Cake/bootstrap.php(175): Configure::bootstrap(true) #4 /var/www/html/my/app/webroot/index.php(90): include('/var/www/html/m...') #5 {main} thrown in /var/www/html/my/lib/Cake/Cache/Cache.php on line 173

Are there any settings in core.php ?

Changed in version 2.5: The Memcached engine was added. And the Memcache engine was deprecated.

Try using the “Memcached” engine instead:

Cache::config('default', array('engine' => 'Memcached'));