I have this in my frontend/SiteController.php
public function actionPage($slug = 'home') {
Url::remember();
$val = Yii::$app->cache->getOrSet($slug, function() use ($slug) {
$model = DBMenu::find()->with('pagesTranslations')->where(['slug' => $slug])->one();
if ($model === null) {
return $this->redirect(['/site/page', 'slug' => 'home']);
}
return $model;
}, 0, new TagDependency(['tags' => 'page']));
$searchModel = new Search();
return $this->render('page',[
'model' => $val,
'searchModel' => $searchModel
]);
}
And this piece of code in backend/PageController.php
public function actionTest() {
TagDependency::invalidate(Yii::$app->cache, 'page');
}
And after I go to this 'test' action and after that go to site/page?slug=home I see in log that DB count is 50 and it should be 68. Why invalidate method doesn't work?
EDIT: In common/config/main.php cache is set like this:
'cache' => [
'class' => 'yii\caching\FileCache',
],