After I update my manufacturer table, I set the global state as follows:
Yii::app()->setGlobalState('manufacturer_updated', new DateTime());
But the cache listing of getAllManufacturers call from dropdown box is not getting refreshed:
<?php echo $form->dropDownList($model,'manufacturer_id', CHtml::listData(Manufacturer::model()->getAllManufacturers(), 'id', 'name'), array('prompt'=>'Select Manufacturer')); ?>
Function in my model called by the dropdownbox:
public function getAllManufacturers()
{
$sql = 'SELECT id, name FROM manufacturer WHERE store_id =:store_id ORDER BY name';
$cmd = Yii::app()->db->cache(72000, new CGlobalStateCacheDependency('manufacturer_updated'))->createCommand($sql); //20 hours cache
$cmd->bindValue(':store_id', Yii::app()->session["current_store_id"], PDO::PARAM_INT);
return $cmd->queryAll();
}
Actually, 2-3 times it worked in the beginning. After that, the cache is never getting refreshed. However, changing the expiry time to 0 causes it to get refreshed. But when I set back the expiry value to its original, the cache strangely brings back its stale data.
Why is this query cache still keeping its stale data?