Answer the question
In order to leave comments, you need to log in
How to list caches or cache tags in Yii2?
There are reports on reporting dates, for each date I create a cache.
Yii::$app->cache->set('report_'.$_GET['DATE_REPORT'].'', $sql, 3600); // ключ 'report_'.$_GET['DATE_REPORT'].''
Yii::$app->cache->set('report_'.$_GET['DATE_REPORT'].'', $sql, 3600, new TagDependency(['tags' => 'report_'.$_GET['DATE_REPORT'].''])); // ключ и тег 'report_'.$_GET['DATE_REPORT'].''
Yii::$app->cache->set('user_42_profile', 'key1', 1000, new TagDependency(['tags' => 'report-123']));
Yii::$app->cache->set('user_42_stats', 'key2', 1000, new TagDependency(['tags' => 'report-123']));
Yii::$app->cache->set('admin_42_profile, 'key3', 1000, new TagDependency(['tags' => 'super-123']));
Yii::$app->cache->set('admin_42_stats', 'key4', 1000, new TagDependency(['tags' => 'super-123']));
TagDependency::invalidate(Yii::$app->cache, 'report-123');
Answer the question
In order to leave comments, you need to log in
Doesn't it bother you that you are not using the cache for its intended purpose? The cache is on the database. The cache should depend on the relevance of the data, and not on the desires of the user.
Relevance is checked at the time of access to data with a specific key. He shouldn't delete anything else. Something else when it is requested, it should understand whether it is relevant or not.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question