Skip to content

Conversation

ArnaudB88
Copy link

Add RemoveAll() method which creates a new cacheprovider
See #67

Add RemoveAll() method which creates a new cacheprovider
public virtual void RemoveAll()
{
CacheProvider.Dispose();
cacheProvider = new Lazy<ICacheProvider>(() =>
Copy link
Contributor

@jnyrup jnyrup Mar 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initializing a new cacheProvider instead of removing the keys from the existing cacheProvider gives inconsistent behavior to how Remove(key) works.
E.g. if the CachingService was instantiated using any of the constructors except CachingService(), then calling RemoveAll will change the underlying cacheProvider to a DefaultCacheProvider.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right.
I made this PR because I use dependency injection to create a CachingService, and the PR #91 doesn't work correctly with DI.
I think it's best to abandon this PR, and edit PR #91 so dependency injection code (asp.net core, ninject) works correctly.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this sort of change will need to incorporate DI so will close in favour of #91

@alastairtree
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants