title: Azure Cache - How to Determine if a Key is in cache?
body: <p>Is there a way, using Azure Caching, to determine if an object having a specific key exists in cache, without actually returning the object itself? </p>
  
  <p>I'm currently doing something like </p>
  
  <pre><code>    public bool IsKeyInCache(string cacheKey)
      {
          DataCacheItem item = null;
          CacheRetryPolicy.ExecuteAction(() =&gt;
          {
              item = cache.GetCacheItem(cacheKey);
          });
  
          return item != null;
      }
  </code></pre>
  
  <p>But, because the object in cache is very large and expensive to deserialize, performance is horrible. </p>
  
  <p>I've dug through the MSDN documentation and don't see any alternative, but maybe I'm missing something. </p>
  
  <p>My best idea so far is to add a small "marker" object to cache at the same time as my large object and check for existence of the "marker" object where deserialization is inexpensive. But this isn't a robust solution, as it's entirely possible for my large object to get purged from cache while the "marker" object remains. </p>