Multiple Caching Methods


I’d like to be able to use both APC and memcached at the same time. I’d like to use APC for Yii core caching, and memcached manually to store some data.

1 - How can I add both of them to the config file?

2 - How can I choose which one of the two to use when doing Example::model->cache(3600)->findAll()?

I tried the following:

'cache' => $params['cache.apc'],

'cache2' => $params['cache.memcache'],

but then I don’t know which one Yii is going to use when I do



It will use the component specified by queryCacheID of the dbConnection from the CActiveRecord, probably the default one for the app.

Use the other cache exactly as you said, define another component.

Thanks a lot for the link.

So considering that

I can just add the following to the config file and it will use memcache instead of apc for caching all the stuff I retrieve on that connection?

'queryCacheID' => 'cache2'

Add this as a property for the ‘db’ component configuration.