Cached Query Still Hits The Database

I’m not sure if I’m doing this wrong. I’m trying to cache a query result:


$teamModel = Team::model()->cache( 100000, null, 100 )->findByAttributes( array( "team_url" => $url ) );

I’ve also tried setting a CDbCacheDependency, but the result is the same. In my log I still see the query being executed:

[sql]system.db.CDbCommand

Querying SQL: SELECT * FROM team WHERE team_url = ‘teamurl’

LIMIT 1[/sql]

then underneath:

[sql]system.caching.CApcCache

Serving "yii:dbquerymysql:host=localhost;dbname=xxx:xxx_user:SELECT

  • FROM team t WHERE t.team_url=:yp0 LIMIT

1:a:1:{s:4:":yp0";s:13:"teamurl";}" from cache[/sql]

Why is the query still being executed? What am I doing wrong?

First query uses table 3hch_team, second - team

Is that an expected behaviour?

Sorry, spelling mistake

What kind of cache do you use in your app?

APC Cache:


'cache'=>array(

	'class' => 'CApcCache',

),

And if you change it to CFileCache will the problem remain?