How to check if a key exists in a MemoryCache
.net, c#, caching
Solution
Use `bool Contains(string key, string regionName)` method.
MSDN:
Determines whether a cache entry exists in the cache. Return Value Type: System.Boolean true if the cache contains a cache entry whose key matches key; otherwise, false. MemoryCache.Contains Method (String, String), MSDN
Problem
I need to check if a key is present in a MemoryCache. However there is no Keys collection or something similar available. I do not need the object associated with the key only a true or false if a certain key is present. I know I can try a .Get(key) but I do not need the object. Is this the only way?