yii2
yii2 copied to clipboard
TagDependency invalidate in console
What steps will reproduce the problem?
I have basic app with same id and cache part config web.php
'id' => 'basic',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
part config console.php
'id' => 'basic',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
in web app I use cache
$kurs = Yii::$app->db->cache(function() {
return static::find()->limit(1)->asArray()->one();
}, Yii::$app->params['cache'], new TagDependency(['tags' => 'kurs']));
in console I reset cache
TagDependency::invalidate(\Yii::$app->cache, 'kurs');
What is the expected result?
reset cache in web
What do you get instead?
cache not resets
but in web TagDependency::invalidate works good
Additional info
| Q | A |
|---|---|
| Yii version | 2.0.13.1 |
| PHP version | 7 |
| Operating system | ubuntu 16 |
is basePath of both applications the same? i.e. do they both use the same runtime path? If not you need to configure FileCache to use the same path.
Its default app with default settings, guess runtime same
I have similar problem... Yii::app->cache is Redis... Yii 2.0.12. TagDependency from console not reset cache... I think about the id in config, but this dont have result
Same here, using memcached and TagDependency in Yii2 web-application.
People using redis as caching-engine has the same problem reported under this issue: https://github.com/yiisoft/yii2-redis/issues/156
Having the same issue with TagDependency here. invalidate() call does not invalidate anything when called from my console application, whereas the same call works in the web app. Web and console app use the same cache back-end configuration (memcached). Everything else related to caching (cache proper, schema caching, flush, etc.) works fine in both web and console app.