2

I am a newbie to php and cakephp, recently I was assigned a job to implement memcache in my app so that its performance can be increased. Can anyone suggest some documentation on this topic for me? Thanks.

3
  • 2
    Are you sure you need memcache to scale your app? Premature optimization is the root of all evil. First write your app, then measure performance, then decide where the performance bottlenecks are, then decide where and what kind of caching or other techniques you need to use. First then use memcached, if necessary. Commented Jan 6, 2011 at 9:12
  • App is already written and working, we found the bottle necks (i.e. mysql queries) so now I decided to use memcached... Commented Jan 6, 2011 at 9:49
  • If your application is not distributed (i.e. only 1 application server), APC provides sufficient caching. You should have it installed regardless so that the byte code from the PHP interpreter gets cached. If you're using CakePHP 2.x, APC is already the default caching algorithm. You can optimize your app using the cache API described at book.cakephp.org/2.0/en/core-libraries/caching.html Commented Oct 23, 2013 at 14:33

3 Answers 3

3

This might be a bit late ... but the Cake core has support for Memcached built in (at least in the latest versions, 2.0.x and 2.1).

Have a look at Config/core.php in your app, and you should see these lines (commented):

   Cache::config('default', array(
          'engine' => 'Memcache', //[required]
          'duration' => 3600, //[optional]
          'probability' => 100, //[optional]
          'prefix' => Inflector::slug(APP_DIR) . '_', //[optional]  prefix every cache file with this string
          'servers' => array(
                  '127.0.0.1:11211' // localhost, default port 11211
          ), //[optional]
          'persistent' => true, // [optional] set this to false for non-persistent connections
          'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
  ));

You can uncomment these lines and test it out with a Memcached install. Make sure you have Memcached installed somewhere (localhost or elsewhere) and you are pointing to it.

Sign up to request clarification or add additional context in comments.

Comments

2

Memcache is one of the supported Cache engines by the built-in Cache class. The Cache class is a wrapper for interacting with your Cache and you can read everything about it here: http://book.cakephp.org/2.0/en/core-libraries/caching.html

3 Comments

Hey Bjorn thanks 4 the reply but i tried it and still not able 2 figure out.
Figure out what exactly? Do you have an exact problem?
Bjorn Your referrer link getting error page. It's bad.
2

Warlock

Here is a more specific implementation of Memcache and Cakephp that may help with your bottle necks

Send your database on vacation by using CakePHP + Memcached

http://nuts-and-bolts-of-cakephp.com/2009/06/17/send-your-database-on-vacation-by-using-cakephp-memcached/

1 Comment

Does Cakephp has a built in Memcache controller??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.