0

I am working with C# and using the asp.net in proc caching framework to cache my large objects. So, I place the object in to .net caching, and look for it in multiple places in my code. After I retrieve the object from cache, I modify it eg. alter properties of the object etc. It seems though, the object is stored in the .net caching by ref as oppose to by value. So if I update the object that has been pulled from cache, it also updates the object within the cache.

Is there any way to avoid this happening - I dont want whats within cache to be reflected by the change.

amateur
  • 43,371
  • 65
  • 192
  • 320
  • possible duplicate of [Asp.Net Cache, modify an object from cache and it changes the cached value](http://stackoverflow.com/questions/2793084/asp-net-cache-modify-an-object-from-cache-and-it-changes-the-cached-value) – Dalorzo Jun 01 '14 at 01:28
  • It's working the way it is supposed to work. You could make a copy of the object and modify that. Or maybe it isn't a good candidate for caching. What is the object and why are you modifying it? – Steve Wellens Jun 01 '14 at 03:25

0 Answers0