Open nnrudakov opened 6 years ago
I guess this is because dependencies are evaluated only when you call get()
not on exist()
Have same problem still. I think that's because of extension just marked records as deleted. Redis worker flush them postponed.
P.S. get()
doesn't helps at all
In my case the reason for invalidate to not work was that the tags weren't saved at all because in the config i had 'serializer' => false
. After I switched to the default PHP serializer, everything worked fine. This is because the dependency is not evaluated at all if the serializer is set to false
@nnrudakov was that the case for you?
Nope. Here my config:
'cache' => [
'class' => yii\redis\Cache::class,
'redis' => 'redisConn',
'keyPrefix' => 'my_pref'
],
In this case serializer
is null
, right? According to docs:
Defaults to null, meaning using the default PHP
serialize()
andunserialize()
functions.
So, I have the default PHP serializer. What I'm doing wrong?
any update on this issue? it doesn't work for me either.
No. Want to work on it?
I guess this is because dependencies are evaluated only when you call
get()
not onexist()
This is the solution.
I'm running into the same problem. Is there any workaround for that? I have several functions, which needs to clear the cache, like this way:
$cache = \Yii::$app->userCache;
TagDependency::invalidate($cache, 'ListOfPosts');
But this seams not to work, even 5 years after this issue was opened. In my application, this problem came up more by accident. I wonder how many Yii2 installations in the world are subtly buggy because the developer didn't notice this bug.
In the last 5 years only a few people have contributed to this issue. Either this feature is rarely used or many don't notice the bug. Finally, this issue is equivalent to an application that generates inconsistent data due to a bug. This is a show stopper in my eyes. It's good to know about this bug. It is better to create a slower application without a cache feature than a performant application that has wrong data.
//Edit: By the way: I'm using memcached as caching-engine and run into the same problem.
What steps will reproduce the problem?
Here a console command action:
What's expected?
I expected that
$key1
and$key2
would not exists in cache after deleting by tag.What do you get instead?
Additional info