Answer the question
In order to leave comments, you need to log in
Yii2 how to set page cache dependency on two tables?
Good afternoon!
There is a CRUD controller for the model, let's say user, it organizes page caching through:
public function behaviors()
{
return [
[
'class' => 'yii\filters\PageCache',
'duration' => 0,
'variations' => [
Yii::$app->request->pathInfo,
Yii::$app->request->get(),
Yii::$app->language,
],
'dependency' => [
'class' => 'yii\caching\DbDependency',
'sql' => 'SELECT MAX(updated_at) FROM user',
],
'enabled' => Yii::$app->request->isGet
],
];
}
...
[
'attribute'=>'restaurant',
'filter'=>Restaurant::nameArrayMap(),
'value' => function ($model){
...
},
],
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question