How to delete cached when using CJuiDialog to update ActiveRecord


By refer to

I tried to create an application to maintain data in database. It works great.

But when I enable cache in main.php, after update a record through CJuiDailog.

A cached file was created, when I click [Edit] button again, this time the old content showed.

I’d tried to use Yii::app()->cache->delete($cacheid); but I can not get the $cacheid. It’s not $model->tableSchema->primaryKey.

So, I add "Yii::app()->cache->flush();"; it works. But I do not want to affect the other cached files.

Does anyone know how to get the $cacheid for remove the cache file?

This questions interests me as well. If I have something like:

$dataProvider = new CActiveDataProvider(Album::model()->cache($duration, $dependency, 2), array(

        'criteria' => $criteria,


How can I possibly set/access the cache key so I can manually unset it later on? I don’t/can’t depend entirely in the $dependency to do that for me.

Why can’t rely entirely in the $dependency object? I have a is_deleted column in the Album table, so when the user ‘erases’ an album, I update the is_deleted to TRUE and the update_time (which is the core of my dependency query). Now, when the user erases his account, I want to erase the Albums, not update is_deleted. And when I do that, the set returned from the cache is inconsistent with the database.

It’d be really good if there was a way of doing something like:

$dataProvider = new CActiveDataProvider(Album::model()->cache($myKey, $duration, $dependency, 2), array(

        'criteria' => $criteria,


This thread ‘explains’ how to get the key, but, honestly, that can’t be the right/only way.