Hi, pepople!
Howto implement\configure switching between multiple caches. For example, to cache data - use CMemCache and for pages and their fragments - CFileCache.
Thanks.
Page 1 of 1
Switching between caches
#2
Posted 12 February 2010 - 11:14 AM
Hi, first of all you should define all possible Cache components in config. Example:cache (uses CFileCache) and remoteCache (uses CMemCache).
Now for fragments-caching. Let's assume you want to cache fragments remotely:
By default, 'cacheID' is set to 'cache'. So if you want to store in file you can just do:
Other components like CCacheHttpSession have also $cacheID attribute. So if you want to store sessions remotely you can do:
Now for fragments-caching. Let's assume you want to cache fragments remotely:
if ($this->beginCache($key, array('cacheID' => 'remoteCache')))
{
// Generate data...
$this->endCache();
}
By default, 'cacheID' is set to 'cache'. So if you want to store in file you can just do:
if ($this->beginCache($key)) // ...
Other components like CCacheHttpSession have also $cacheID attribute. So if you want to store sessions remotely you can do:
'components' => array(
...
'session' => array(
'class' => 'CCacheHttpSession',
'cacheID' => 'remoteCache',
),
...
),
#3
Posted 12 February 2010 - 12:03 PM
Y!!, on 12 February 2010 - 11:14 AM, said:
Hi, first of all you should define all possible Cache components in config. Example:cache (uses CFileCache) and remoteCache (uses CMemCache).
Now for fragments-caching. Let's assume you want to cache fragments remotely:
By default, 'cacheID' is set to 'cache'. So if you want to store in file you can just do:
Other components like CCacheHttpSession have also $cacheID attribute. So if you want to store sessions remotely you can do:
Now for fragments-caching. Let's assume you want to cache fragments remotely:
if ($this->beginCache($key, array('cacheID' => 'remoteCache')))
{
// Generate data...
$this->endCache();
}
By default, 'cacheID' is set to 'cache'. So if you want to store in file you can just do:
if ($this->beginCache($key)) // ...
Other components like CCacheHttpSession have also $cacheID attribute. So if you want to store sessions remotely you can do:
'components' => array(
...
'session' => array(
'class' => 'CCacheHttpSession',
'cacheID' => 'remoteCache',
),
...
),
Ohhh! I missed 'cacheID' param in api book. Thank you! It's working!
Share this topic:
Page 1 of 1

Help












