I am writing a .net c# application.
I retrieve some data from an xml file, cache the data to the .net cache and return it from my method. I perform some processing on the data and return it another part of my application.
Next call, I read from cache, process it and return it etc.
The problem I have is that the processing performed on the cache data seems to modify the cache and not the local variable which means the next time I read from cache, its the processed data from the previous processing that is returned.
So it seems that the data returned from cache is returned by ref and not value.
Any idea how I can prevent the cache being modified?
Depending on the type the solution may simply be to clone the object/item on retrieval from the cache.