alastairtree / LazyCache

An easy to use thread safe in-memory caching service with a simple developer friendly API for c#
https://nuget.org/packages/LazyCache
MIT License
1.72k stars 159 forks source link

Added a RemoveAll function to clear the entire cache #91

Open migr1 opened 5 years ago

migr1 commented 5 years ago

Fixes #67 Implemented by internally creating a new IMemoryCache instance.

lunar-safari commented 4 years ago

This would be great. To have the ability to 'nuke' the entire cache with a simple _cache.RemoveAll() would be very valuable.

unruledboy commented 4 years ago

When will we merge this PR? I need this in our project.

Thanks.

genpri commented 4 years ago

This is much needed in our project also. Any estimation to when its going to be merged?

Thanks.

rothschild86 commented 4 years ago

+1

Leftyx commented 4 years ago

Could you please merge this feature ?

maranmaran commented 4 years ago

+1

ArnaudB88 commented 4 years ago

Does not work correctly in my project (working with dependency injection)

ArnaudB88 commented 4 years ago

The dependency injection code should also be changed. More specific in:

How should it be changed? There are 2 options: Option A: work with a cacheProvider factory function

Option B: make IMemoryCache registration with TransientLTM

Both options have the same result. Personally I prefer option A, so no other code can request an instance of IMemoryCache.

migr1 commented 4 years ago

@ArnaudB88 Does the new injection code look ok?

ArnaudB88 commented 4 years ago

@ArnaudB88 Does the new injection code look ok?

Looks fine to me. But it's good to let it review by someone else than me. I have experience in other DI containers than Ninject and MS.DI. But option A looks good to me :)

svengeance commented 4 years ago

@alastairtree Is there anything preventing this from going forward?

alastairtree commented 4 years ago

I am still thinking about if, and how, LazyCache should support a delete everything feature. In the meantime I have added 2 ways of achieving the same thing without changes to LazyCache to the docs.

svengeance commented 4 years ago

@alastairtree Would it be possible for you to publish an update or some high level overview of what your plans are for this project? It'd be cool to see what you think it should do, what it's doing right, what it can do better, etc? This would help me (and others) identify issues and places to come in with PRs

Good to know there are alternatives for emptying the cache as well

ArnaudB88 commented 4 years ago

@alastairtree This pull request is basically your first method to empty the entire cache. In my opinion, a clean and more easy to understand way than method 2. It just adds a change of passing a MemoryCache function instead of an instance.

alastairtree commented 4 years ago

@alastairtree Would it be possible for you to publish an update or some high level overview of what your plans are for this project? It'd be cool to see what you think it should do, what it's doing right, what it can do better, etc? This would help me (and others) identify issues and places to come in with PRs

Very fair - my ability to maintain this project, like all open source is time limited. Key requirements for all changes are that LazyCache should be small, fast and as easy to use as possible, and it should remain current with the latests dot net. In this respect the majority of functionality is done but as you know there are always improvements that can be made. I have done a bunch of housework on the issue list so it is now more manageable and current, and marked many of them as help wanted where PRs would be appreciated so please take a look.

alastairtree commented 4 years ago

I have added a long comment detailing some of the challenges with this feature on the issue below which should help explain why it's not yet merged https://github.com/alastairtree/LazyCache/issues/67#issuecomment-696413932