Hi Joshua,

> Thanks your reply!  Is that means if we want to use the sort or paginate
> function , we shouldn't use the view cache feature in our application? I
> want to know what you will do if you want to improve your application
> performance? Is there any friends who use the view cache feature in your
> application ?

You can still use caching, but not on the view, although you could
create an element for each alternative sort, eg:

/elements/tables/data_name_asc
/elements/tables/data_name_desc
/elements/tables/data_created_desc

I'd have thought that was pretty inefficient though, and certainly
doesn't scale well! I would cache the data returned by paginate.
You'll need to cache each dataset, eg, for every change of sort and
direction, but the element can stay the same. Something like:

// Cache name - just a simple example
$cacheName = $this->name.'_'.$this->action.'_'.join('-',
$this->paginate[$this->modelClass]);

// Look for cached data
if (($this->data = Cache::read($cacheName) === false)
{
        // Didn't find any so get data
        $this->data = $this->paginate($this->modelClass, $conditions);
        // write to cache
        Cache::write($cacheName, $this->data);
}

hth

Jon



jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to