The answer to RC1 is that you cannot make it out of the box from what I read and said (I read on GitHub that there may be a way to create triggers to facilitate this, what happens),
You are currently provided with Get, Set, and Remove. I see your options as:
- Create a cache manager wrapper that will keep track of all your keys, and then you can remove these items in bulk if you want. I'm not in love with this, but it will work. Of course, if you do not control the addition, there may be things in the cache that you do not know about (you could compare your score with it to see). If you click IMemoryCache as MemoryCache, you can get the public property Count.
- Build and print the Keys and / or add a method for deleting these elements. There is a main dictionary containing keys. I did this, compiled it by creating a Nuget package for it, and then replaced the RC1 version to see if I could (and it worked). Not sure if this is the right way, but here is fixing my plug, I just added a read-only property, where I dumped the keys into the list of objects (keys are stored as objects). As in previous implementations of MemoryCache, if you opened the keys, they may be outdated after they were reset, but if you just use them to clear all, then it does not matter.
https://github.com/blakepell/Caching/commit/165ae5ec13cc51c44a6007d6b88bd9c567e1d724
I posted this issue last night, trying to figure out if there is a good way to check what exactly is in the cache (ask why we donβt have a way). If you donβt ask, you will never know if this matters, so I understood why not.
https://github.com/aspnet/Caching/issues/149
b.pell
source share