1

以下是我在 Yii 中的数据库缓存的配置代码

'dbcache'=>array(
            'class'=>'system.db.CDbConnection',
            'connectionString'=>'sqlite:/' . str_replace('\\','/',str_replace('C:\\','',getcwd()).'/protected/data/cache.db'),
            ),

以下是我在缓存中获取记录集和设置的代码:

$recordset = Table1::model ()->cache(0)->find ( "primary_id=:id", array (":id" => $id) );

我使用0作为缓存持续时间,因为我需要让它无限期。现在我需要刷新我的缓存。在某种条件下。如果持续时间是无限的,如何刷新 Yii 中的查询缓存。请帮忙 :)

4

1 回答 1

1

首先,将值设置为0并不意味着您设置为无限期。这确实意味着您只是禁用了缓存。

参考代码:类参考 - CActiveRecord

如果要刷新模式缓存,请将代码用作Yii::app()->schema->refresh()

于 2015-05-12T19:45:46.577 回答