Hi guys, I was hoping some of you might have some insight on how to solve this problem: I currently have a CActiveDataProvider with cache enabled using a CDbCacheDependency enabled. I really want to change this dependency, cause I don’t want to have to touch the database unless it’s completely necessary. I tried replacing the DbCacheDependency with a GlobalStateCacheDependency but my app is big and have many concurrent users, so it’s off the table. Then I tried CExpressionDependency with something like:
new CExpressionDependency(“Yii::app()->cache->get(’$key’) == ‘loadFromDatabase’”);
but it doesn’t seem to work as expected.
Then I tried (in my controller):
$duration = 1800;
if(Yii::app()->cache->get('$key') == 'loadFromDatabase'){
$duration = 0;
}
$dataProvider = new CActiveDataProvider(MyModal::model()->cache($duration, null, 2)));
but this doesn’t work either (works the first time that $duration = 0, but then the old value comes back).
Do you guys know ANY way to invalidate a CActiveDataProvider cache?
Thanks in advance!