Yii Memcached

Hi, maybe someone can help:

i’m following this: http://www.yiiframework.com/doc/guide/1.1/en/caching.data

$dependency = new CDbCacheDependency(‘SELECT MAX(update_time) FROM tbl_post’);

$posts = Post::model()->cache(1000, $dependency)->findAll();

my questions are:

  1. is the query fetched from the cache if exist or only stored with this procedure?

  2. If the dependency is evaluated every time by querying the database where is the offload from the databse (it will get hit every time anyway…?)

Thanks,

Danny

bump…no one?

I suppose the benefit occurs if the query that checks whether the cache is still valid is much simpler than the query that generates the cache. In that case, you may be hitting the database every time, but the query might run faster and lock fewer rows, so reducing database contention.

With regard to your first question, I think it’s very clearly explained in the guide: