Pergunta

I have to cache view (HTML) using CFileCache and (varaible, object) using Memcache.

how to configure it at the same time:

what I need like :

in views

<?php if($this->beginCache($id)) { ?>
...content to be cached...
<?php $this->endCache(); } ?>
...other HTML content...

so the execution of previous code it will output file like (xxxxxx.bin)

and in my acton I have to save in memory (Memcache) like:

$user = $this->getUserById(2);
Yii::app()->cache->set('user2', $user);
Yii::app()->cache->get('user2');

So all variable and objects will saved in Memory

and my main.php:

'cache'=>array(
   'class'=>'system.caching.CFileCache',
 ),

in addition ,if I have to use APC for opcode how to configure it with other cache type to use more than one cache type in my application.

Any help abut how to configure that.

Thanks

Foi útil?

Solução

I have not tested this, but you can try to define something like

'cache'=>array(
   'class'=>'system.caching.CFileCache',
 ),
'memcache'=>array(
   'class'=>'system.caching.CMemCache',
 ),

Then you should be able to do

Yii::app()->memcache->set('user2', $user);
Yii::app()->memcache->get('user2');

I really have not tried this but considering how you define db connections and other things in Yii this should work.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top