yii provide a cache dependency method "means that cache can be invalidated if dependency is not the same as in cache"
one of these dependency method is CDbCacheDependency which execute database query and compare result to dependency stored in cache
but one of the main important points in caching in general that it decrease load on db by decrease number of queries depending on cached query
so if we use CDbCacheDependency i think we are not doing any thing by cache even if the returned value is the from database query is small
i think that if we create a method for deleting cache on update will be better in case of using database dependency
as it will enforce query to execute again
an example of that in my opinion is when you store user sessions in database you need to validate these session with every request sent from user "for security not depending on cookies alone"<this will cause overload on database
i open discussion for this topic to get the best practice using cache dependency.
Yes, I would also like the logic or benefits behind using database cache dependancy to invalidate a cache against just plainly deleting the cache on update.
I think you are viewing caches as a method to conserve db queries too much. Just keep in mind that Yii features infrastructure for caching on very different levels. This involves the caching of entire rendered pages. In this context, it makes actually a lot of sense to avoid the (possibly costly) re-rendering by means of a light sql query.
Can be surely done. If you’ve got the cache entries’ key (or if you can derive it from the data you’ve got on hand), you can delete the entry from the cache. In fact, this doesn’t conflict the slightest with the way caches work in Yii
OK actually i admire the caching system of Yii as it not using filecache alone but can use memcahce which is not suitable for page caching,also you can use a different caching methods in the same application which is fantastic
try using memcache instead of just query database and you 'll see a great difference