title: Asp.Net Cache, modify an object from cache and it changes the cached value
body: <p>I'm having an issue when using the Asp.Net Cache functionality.  I add an object to the Cache then at another time I get that object from the Cache, modify one of it's properties then save the changes to the database.</p>
  
  <p>But, the next time I get the object from Cache it contains the changed values.  So, when I modify the object it modifies the version which is contained in cache even though I haven't updated it in the Cache specifically.  Does anyone know how I can get an object from the Cache which doesn't reference the cached version?</p>
  
  <p>i.e.</p>
  
  <p>Step 1:</p>
  
  <pre><code>Item item = new Item();
  item.Title = "Test";
  Cache.Insert("Test", item, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
  </code></pre>
  
  <p>Step 2:</p>
  
  <pre><code>Item item = (Item)Cache.Get("test");
  item.Title = "Test 1";
  </code></pre>
  
  <p>Step 3:</p>
  
  <pre><code>Item item = (Item)Cache.Get("test");
  if(item.Title == "Test 1"){
      Response.Write("Object has been changed in the Cache.");
  }
  </code></pre>
  
  <p>I realise that with the above example it would make sense that any changes to the item get reflected in cache but my situation is a bit more complicated and I definitely don't want this to happen.</p>