CakePhp包含模型缓存

I'm using cakephp. In some query I use these kind of find:

$this->Photo->Behaviors->attach('Containable', array('autoFields' => true));

This is the Contain array that i use in the find:

'contain'=>array(
    'User'=>array('fields'=>array('User.Name','User.Username')),
    'Like' => array('User'=>array('fields'=>'Name'),
                    'order'=>'Timestamp DESC'
                  )),
'recursive' => 2, 

The problem is that every time i want the Name of User that liked a photo. Cakephp does this query.

For example: SELECT `User`.`Name` FROM `Users` AS `User` WHERE `User`.`id` = 2175

If i have 300 likes on one photo i will make another 300queries for the User.Name. So, I would like to cache this kind of request. I've installed memcache correctly in my server, it's working normally. But I can't find a way to cache the query that cake make with the Containable Behaviors.

Has some one had this problem?

Thanks G.

Why not use cakephp's counterCache feature instead?

There is a lot of documentation in the cakephp book about caching queries not just in me cache but many other ways as well such. Check out the CakeCache class.

there are a number of approaches on this topic. if it is only about belongsTo relations it boils down to manually join tables using bindModel().

here is a good behavior: http://planetcakephp.org/aggregator/items/891-linkable-behavior-taking-it-easy-in-your-db

it takes care of that itself.