Closed saip106 closed 6 years ago
foreach(var item in MemoryCache.Default) { ... }
?
Thanks for the reply @burnchar. Since we are abstracting MemoryCache using the IAppCache, shouldn't we expose a method on it that does this? I thought accessing MemoryCache directly was not a good idea. What are your thoughts on that?
A good point, @saip106. I believe this is a matter of opinion. I had written my previous reply just after reading this StackOverflow post which describes how iterating a MemoryCache instance is slow, involved, and not recommended in production code. It seems unlikely that LazyCache could do much to improve the experience other than providing a simple wrapper, and doing so would perhaps encourage usage, which Microsoft suggests avoiding.
My impression is that LazyCache is less about abstracting MemoryCache than itself than about providing a well-tested, elegant use of LazyMemoryCache.Default
.
LazyCache could have many features it does not have now, but I rather like its simplicity. The code at present is so small and well-written, I could easily maintain it in my projects if alastairtree chose to move on.
Thanks @burnchar for the detailed reply. I really appreciate you taking time to explain why you think it's not a good idea to add that to the API. I agree with your reasoning. I am closing this issue.
We have a need to see what all items are in cache. Is there a plan to support this? Can I send a pull request?