the Cache method of yii has the parameter cache time to set the cache e.g. 10 minutes valid. I want to set the cache valid until the next day (midnight).
Do you know if this feature is built-in yii? I could use CDbCacheDependency and do:
Yii::app()->cache->set($id, 0, new CDbCacheDependency('SELECT CURDATE();'));
Is this the way to go? Or is there a better way without using db?
My fist idea: create a new CacheDependency class, for example:
class CurrentDateCacheDependency extends CCacheDependency
{
public $format;
public function __construct($format=null)
{
$this->format=$format;
}
protected function generateDependentData()
{
if($this->format!==null)
return date($this->format);
else
throw new CException(Yii::t('ext','CurrentDateCacheDependency.format cannot be empty.'));
}
}