FusionCache icon indicating copy to clipboard operation
FusionCache copied to clipboard

[FEATURE] Expire entire cache

Open giulianob opened this issue 2 years ago • 2 comments

Problem

I have a backplane which pushes updates to the cache. I'd like to expire the entire cache (not remove the items) if the backplane connection is severed.

Solution

Ability to call ExpireAsync on the cache or some way to achieve this.

giulianob avatar Oct 05 '23 18:10 giulianob

Hi @giulianob , I'm not sure I understand the scenario you have in mind.

May I ask you to try to explain it a little bit more? Maybe with a concrete example, a step-by-step list like:

  • I do this
  • and this happens
  • then this happens
  • etc

Thanks!

jodydonetti avatar Oct 08 '23 19:10 jodydonetti

@jodydonetti

The use case is as following:

  • There is a custom backplane implementation
  • When an item changes, the backplane pushes a message to all of the connected clients
  • When a client receives backplane message, the item should be expired from the cache (not removed)
  • If the connection between the client and backplane is disconnected, all items in the cache should be marked as expired (because the client may have missed item change messages)

giulianob avatar Oct 09 '23 18:10 giulianob

Hi @giulianob , sorry for the delay but somehow I lost track of this issue.

Anyway, currently there's no ready made solution to cover this particular scenario, and in general it's not possible to completely clear a cache, for various reasons.

If you want to learn more about why this is the case and what other people do think, I suggest to take a look at the issue currently unfolding about the new distributed cache effort going on for .net 9 , it's ful of interesting experiences and ideas.

I'm closing this since, in general, a Clear() method cannot be supported, but if something new comes up I'll gladly reopen it.

jodydonetti avatar Feb 18 '24 18:02 jodydonetti