Query cahing with infinite expire time not working.


I’m using query caching with infinite expire time. Consider a piece of code below for example:

	$channels  = Channels::model()->cache(0)->findAll(array('order' => 'channel_name'));	

This statement is supposed to make in entry in the cache and it is doing, but it is not fetching the data from cache, rather it is directly going yo DB for the result.

While, if I provide a expire time > 0 (zero), then it works smoothly. For example:

        $channels  = Channels::model()->cache(20)->findAll(array('order' => 'channel_name'));	

works perfectly for 20 seconds and fetch the results from cache.

We are confirmed about it as we enabled the log and saw the profiling.

Infinite expire time works also fine for caching key/value pair using Yii::app()->cache->set/get

Any idea if im doing anything wrong ?


So I came to know that query cache with (0) value will actually disable the cache.

Thanks to the answer against the question I posted here.



I’m using CHttpCacheFilter in my website successfully, and it’s infinite. The cache will clear When you change the “lastModified” parameter.


	public function filters()


	    return array(



            	    'lastModified'=> 1420395125,




Config > main.php