Himanshu
Himanshu

Reputation: 1443

How to implement memcache in cakephp?

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.

Upvotes: 2

Views: 9624

Answers (3)

Bjorn
Bjorn

Reputation: 5362

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

Upvotes: 2

Suman
Suman

Reputation: 9571

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.

Upvotes: 3

jbrass
jbrass

Reputation: 941

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/

Upvotes: 2

Related Questions