Querying Instead Cache?

This is (shorter) table structure:

  • id

  • name

  • last_date

This is code:




            $dependency = new CDbCacheDependency('SELECT MAX(last_date) FROM table WHERE id='.$id); 

            $post= Post::model()->cache(3600, $dependency)->findByPk($id);




Using CWebLogRoute I see:

02:17:50.937169 trace system.db.CDbCommand


Querying SQL: Select t.id, t.name, blabla FROM post blabla

02:17:50.937511 trace system.db.CDbCommand


select max(date) from post where id=blabla

02:17:50.938518 trace system.caching.CApcCache


Serving... bla bla (this is from cache)

Why do I have these frist system.db.CDbCommand?

Tnx

Ok. Maybe this can help (another example)

Is this OK? I think there only should be:

SELECT MAX(IDdrzava) FROM drzava

and next one like "serving…"

update

Do I get that right? You’re using query caching in order to cache a single record? ???

In any case: IIRC, Yii’s profiling output is a bit confusing in that part. It won’t tell you if a query result has been fetched from the cache or fresh from the db right away.