arfeen
(Arfeenster)
January 9, 2015, 10:07am
1
Hi
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 ?
thanks.
arfeen
(Arfeenster)
January 10, 2015, 9:08pm
2
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.
Thanks
Arfeen
arfeen:
Hi
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 ?
thanks.
oligalma
(Marc Oliveras)
January 11, 2015, 3:19am
3
I’m using CHttpCacheFilter in my website successfully, and it’s infinite. The cache will clear When you change the “lastModified” parameter.
Controller.php
public function filters()
{
return array(
array(
'CHttpCacheFilter',
'lastModified'=> 1420395125,
),
);
}
Config > main.php
'components'=>array(
'cache'=>array(
'class'=>'CDbCache',
),
'db'=>array(
'class'=>'system.db.CDbConnection',
'schemaCachingDuration'=>3600,
)
)