title: Using of Interlocked.CompareExchange
body: <p>guys,</p>
  
  <p>I would like to you evaluate next code below.
  As you see, I use Interlocked.CompareExchange, does it make sense in this context? (I am not sure, that it is correct).</p>
  
  <p>I'll be glad any notes, comments, etc.</p>
  
  <pre><code>private static T GetItem&lt;T&gt;(string cacheKey, Func&lt;T&gt; getItemCallback) where T : class
  {
      var item = (HttpRuntime.Cache.Get(cacheKey) as T);
  
      if (item != null)
      {
          return item;
      }
  
      item = getItemCallback.Invoke();
  
      if (item != null)
      {
          HttpContext.Current.Cache.Insert(cacheKey, item);
      }
  
      return item;
  }
  
  public T Get&lt;T&gt;(string cacheKey, Func&lt;T&gt; getItemCallback) where T : class
  {
      var item = (HttpRuntime.Cache.Get(cacheKey) as T);
  
      if (item != null)
      {
          return item;
      }
  
      Interlocked.CompareExchange(ref item, GetItem(cacheKey, getItemCallback), null);
  
      return item;
  }
  </code></pre>
  
  <p>Thank you advance.</p>