Cache query of CActiveDataProvider

Hi,

I want to cache a CListView (I use APC Cache Component).

I don’t want just to do fragment cache,I want to cache the query that populates the CListView with items.

The problem is,CListView uses a CActiveDataProvider,and the query is hidden inside the provider,so I don’t see how I can use the instructions for query caching provided by the Yii guide.

Any suggestions?Thanks in advance.

Try this:

http://www.yiiframew…ang=&type=forum

I thought I knew the answer, but I didn’t. So I searched for it - and realized that instead of copying and pasting the results here, I’ll let you choose what you need. :)

Thank you,I found a solution in your results.Someone had the same problem and extended the CActiveDataProvider Class to make a new cached version.People will go that far for those extra hundrendths of seconds!

CActiveDataProvider takes either a model name (string) or instance (e.g. Post::model()) as an argument to its constructor, so you can also just pass it a model instance with the cache() configuration using the method chaining syntax.

A more thorough explanation and an example can be found here:

http://www.yiiframework.com/wiki/233/using-cache-in-cactivedataprovider/