-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to flush all cache? #36547
Comments
Related: aspnet/Caching#93 |
Responding to dotnet/extensions#93 being related I think and support there should be a cache clear option. Reasons could be
|
I was curious about the same thing. Further, from a diagnostics perspective I wanted to know everything that was in the cache (the argument of whether or I should or shouldn't iterate over cache keys aside). If I cast IMemoryCache that was injected as MemoryCache I was able to get the Count property but no keys exposed. Looking at the MemoryCache class there was just a Dictionary behind it like in past versions. I forked the project at RC1, added a Keys property onto the MemoryCache class that returned the keys from the Dictionary. Built that, put the Nuget output into my custom Nuget feed and then updated my Nuget packages and let it do the rest. |
+1 to adding a I now expose a cache clearing method in my controllers as a matter of course. This stops you having to use the nuclear option of restarting the site to clear As it is, I will now have to keep a list of all my keys. Not a fun thing to do. |
For those looking for a workaround, I have written and tested the following helper class with a
|
This is what I currently have to do with System.Runtime.Caching:
I really, really want to stop doing this. |
So, @RehanSaeed what's the status on this matter? Do you have an example? |
Sadly, nothings changed. Still waiting for this functionality. |
I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label. |
The issue has been open for 5 years. Nothing changed. It's a very common request to clear all cache items in the memory. |
Please can this issue be added as I am having immense issues flushing keys manually. Thank you |
What would this look like as an API? (general format shown in https://github.com/dotnet/runtime/issues/new?assignees=&labels=api-suggestion&template=02_api_proposal.md&title=) |
Related to #36568 |
I've created a new issue with the proposal: #45593 |
We've reached feature complete for .NET 6. Moving to 7. |
A Clear() method was added to MemoryCache in #45593. Closing as completed. |
No description provided.
The text was updated successfully, but these errors were encountered: