Answer the question
In order to leave comments, you need to log in
Yii2 how to set custom yii\caching\Cache\buildKey for a module?
Hello!
There is an idea to use pseudo-tags in caching at the level of cache keys, like:
['|blog|', '|user|', '|userstat|', '|commentcount|', '|uid=777|']
so that if necessary the entire cache could be broken as needed fragmentarily. For example, if a user commented on something, they cleared him and only his cache of statistics, latest comments, all comments, and various other useful garbage.
but, the regular buildKey breaks this topic with its
md5 (json_encode ($ key))
is there a way for a separate module to override only this method?
Answer the question
In order to leave comments, you need to log in
In general, it seems to work like this:
In the module initialization file, write like this:
if (!empty($this->components['cache'])) {
yii::$container->set(
'cache',
['class' => $this->components['cache']['class']]
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question