Memcached optimization


Swapping out CakePHP’s default file logging for memcache can greatly improve performance. In my case I use couchbase server to manage NoSQL. From there administrative panel you can see every time your app has a page refresh.

Couchbase Server default bucket

Memcached optimization with CakePHP 2.x

To connect CakePHP with memcached place this in your app/Config/core.php

Cache::config('default', array(
	'engine' => 'Memcache',
	'prefix' => Inflector::slug(APP_DIR) . '_',
	'servers' => array(
			'' // localhost, default port 11211
		), //[optional]
	'duration' => 7200,
	'serialize' => false,
	'persistent' => true, // [optional] set this to false for non-persistent connections
	'compress' => false,
	'probability' => 100 

Your application will now benefit from using memcache instead of a standard logging system. In the event that you make major changes to you application you may need to “flush” the memcache bucket to clear the cached schema stored by CakePHP.

Leave a Reply

Your email address will not be published.