-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selecting cache key starting with something? #66
Comments
The simple answer is that key iteration is blocked on the new version of MemoryCache, the underlying Microsoft library LazyCache builds on top of, so LazyCache cannot easily give you a built-in way to solve it. Blocking iteration on all the keys is sensible for performance and concurrency reasons. This is a breaking change in the upgrade from 0.7 to 2.0. To solve your requirement I can think of two ways:
IAppCache productCache = new CachingService(new MemoryCacheProvider(new MemoryCache(new MemoryCacheOptions())));
// do some caching
// and then later on when you want to clear it - dispose and recreate
productCache.CacheProvider.Dispose();
productCache = new CachingService(new MemoryCacheProvider(new MemoryCache(new MemoryCacheOptions())));
Does this allow you to work around the change? |
@alastairtree Cheers thanks for that, I actually ended up going for the second version which does the job for now. I like the suggestion to have a wrapper with extension methods. Maybe if other people require this functionality it might be worth looking into making it a feature for your library |
#86 Has a pull request maintaining an internal cache key list |
This is a very similar to #74 and I have added a workaround to clearing a range of items using cancellation tokens as a comment there which may be useful to folks who find this ticket. |
Great library,
I was wondering is there a way to remove cache key based on a selector such as remove all keys starting with "product-id-" ?
As similar question was asked here:
#6
Looking for something like below, but for .net core
Also is the a feature where a cache object can be dependent on another cache object.
i.e. Cache A has a dependency on Cache B (when it's cleared), I would like cache a to be cleared too
The text was updated successfully, but these errors were encountered: