I have a little function to get some results from db. Since the actual query could hang up pretty long on a big database I decided to use the CDbCache functionality a little bit to cache results for 1 hour.
function getResults () {
if ( false != $results = Yii::app ()->cache->get ( 'cacheIndexKey' ) ) {
return $results;
}
$results = ModelName::model ()->findAllBySql ( "
SELECT
*
FROM `table_name`
" );
Yii::app ()->cache->set ( 'cacheIndexKey', $results, 3600 );
return $results;
}
Problem is that, despite the fact that I see the cache table being populated with data, the sql still gets executed at every request no matter what.
Any ideas?