title: Duplicate keys while adding data to cache
body: <p>I'm using the following code to add data to my cache:</p>
  
  <pre><code>public void Add(string key, object item, int duration)
      {
          if (DataCacheHelper.DataCache.Get(key) == null)
          {
              if (duration &gt; 0)
              {
                  DataCacheHelper.DataCache.Add(key, item, new TimeSpan(0, 0, 0, 0, duration));
              }
              else
              {
                  DataCacheHelper.DataCache.Add(key, item);
              }
          }
          else
          {
              Update(key, item);
          }
      }
  </code></pre>
  
  <p>Notice how I have the 'if' statement before I add the data to either add it or update.</p>
  
  <p>Still with this code I'm still getting the following error:
  <a href="https://i.stack.imgur.com/OtR1D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OtR1D.png" alt="enter image description here"></a></p>
  
  <p>Does anyone know what I'm missing in all this?</p>
  
  <p>The program is running on an Azure Cloud service with 2 instances. Not sure if that has anything to do with it.</p>
  
  <p>Thanks.</p>