Reputation: 27
I want to use tagging cache in Yii.
But it turns out that for the frontend using its cache for its backend. When I do change the model in the backend, the front of the cache is not cleared. There are any solutions for this?
Sorry for my english.
Upvotes: 1
Views: 1119
Reputation: 1684
In my case, at runtime of caching service in DI, for FileCache, setting another cachePath also works fine.
//in backend
$cache = \Yii::$app->cache;
if ($cache instanceof FileCache) {
$cache->cachePath = \Yii::getAlias('@frontend/runtime/cache');
$cache->set('my_cache_prefix', $myData);
}
//This way I have overridden expired cache in frontend
Upvotes: 0
Reputation: 2499
Set distinct cache prefix for frontend and backend in their respective configuration files.
I am still using 1.1.x branch, but for 2.x branch should be the same thing.
Frontend configuration file:
'cache' => array(
'class' => 'system.caching.' . (!MW_DEBUG ? 'CFileCache' : 'CDummyCache'),
'keyPrefix' => md5('frontend.' . MW_VERSION . Yii::getPathOfAlias('frontend')),
),
Backend configuration file:
'cache' => array(
'class' => 'system.caching.' . (!MW_DEBUG ? 'CFileCache' : 'CDummyCache'),
'keyPrefix' => md5('backend.' . MW_VERSION . Yii::getPathOfAlias('backend')),
),
Upvotes: 1