Search Keyword MemoryCache

I am trying to find a way to make an instance of .net 4.0 MemoryCache.Default using case-insensitive matching.

Is it possible?

var bob = new object(); MemoryCache.Default["Bob"] = bob; bob == MemoryCache.Default["bob"]; --> true 
+6
source share
1 answer

From looking at the code through ILSpy , this is not possible. Because behind the scenes, GetHashCode() your key string is ultimately used.

I think the easiest way to do this is to implement a custom cache by expanding MemoryCache , which overrides all methods that interact with the key and calls ToUpperInvariant() , passing it as a parameter to the base call.

+5
source

All Articles