Closed kelko closed 1 year ago
Hi @kelko and thanks for using FusionCache!
What you are looking for is normally referred to as a Clear()
method, and has been requested multiple times like here or here: there you can read the rationale behind not having such a method (and now with Named Caches and Cache Key Prefix even more).
In particular in the second link you can see a potential solution which may be useful to you.
Hope this helps.
Problem
internal caches of a ASP.NET WebAPI need to be invalidated in certain conditions (externally triggered). Cache Invalidation per key (cache.Remove(key)) is not suitable, we don't know all keys up front.
Solution
per (named) cache a method to remove / invalidate all entries of the whole cache, on all levels
Alternatives
Additional book-keeping to track all cache keys created, so they can be removed each one individually
Additional context
.NET 7 ASP.NET WebAPI using FusionCache via DI