开发者

How to implement memcache in cakephp?

开发者 https://www.devze.com 2023-02-02 23:57 出处:网络
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 do开发者_运维问答cumentation on this t

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 do开发者_运维问答cumentation on this topic for me? Thanks.


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.


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


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消