ZiggyCreatures / FusionCache

FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
MIT License
1.65k stars 87 forks source link

[FEATURE] Invalidate complete cache #166

Closed kelko closed 1 year ago

kelko commented 1 year ago

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

jodydonetti commented 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.