CDbCacheDependency not resetting cached value

I have a Yii (1.1.14) application that uses CMemCache for caching.

I am consistently having a problem with Yii "ignoring" cache dependencies and loading the old, obsolete data from the cache.

Code sample:




$dependency =  new CDbCacheDependency('SELECT MAX(GREATEST(created, modified)) FROM brand');

$model = Brand::model()->cache(3600 * 24, $dependency)->find(array(

    'condition' => "REPLACE(name, ' ', '-') LIKE :id",

    'params'    => array(

        ':id'   => $id

    )

));



I have confirmed that even when the result of the dependency query changes (I ran the query in phpMyAdmin before and after modifying the record), the cache is not refreshed.

I am having this problem consistently throughout the application. The tables in question are InnoDB tables (MySQL) if that makes a difference

its weird I am also using memcache driver running in production since 2011 never had issue


I use only one columns modified as criteria to check for updates I touch both fields created, modified when i create the records

"SELECT MAX(modified) FROM tableName"

Chaim, what’s your scenario? If you’re deleting a record, make sure you’re not actually deleting but marking it as ‘deleted’ using an extra column and updating the ‘modified’ column.