Hi everybody,
It’s my very first time using caching, and I’m not sure if what I’m doing is right or not.
In my web I have a search, you must enter country for exaple, and depending on the country you enter you are given a list of results.
To get this list of result I use a dataprovider and then I pass it to a gridview and then render it, so first of all I’m not sure if I can use cache for this search due to each search could be different.
So how can I manage cache to handle it? Should I have different dependencies for the most common countries and dependenig on wich one is searched I use one or another dependency?
Actually the sql search is extremly more complicated beacuse there are not only countries, but there are also cities, stablishments and more things…but is easier to explain myself with this simple example.
Anyway I enabled cache in config main :
'components'=>array(
'cache'=> array(
'class' => 'CDbCache'
),
And in my controller I tried this:
$dependency = new CDbCacheDependency('SELECT count(id) FROM countries');
$dataProvider=new CActiveDataProvider(Countries::model()->cache(36000,$dependency,2), array(
'criteria'=>array(
'with'=>$dataProviderWith,
'condition'=>$parametros,
'having'=>$having,
'group'=>'t.id',
'order'=>$order
),
'pagination'=>array(
'pageSize'=>8,
),
))
But it doesn’t work, because the time search takes is the same in the first time and in the second and so on… I can’t notice any time response improving due to cache handling.
Please help me!