[Solved] C# MemoryCache Changing Data by Itself

Change: Utility.CacheHelper.SaveTocache(“MyKey”,a); to: Utility.CacheHelper.SaveTocache(“MyKey”,a.ToList()); and: List<String> b = Utility.CacheHelper.GetFromCache<List<String>>(“MyKey”); to: List<String> b = Utility.CacheHelper.GetFromCache<List<String>>(“MyKey”).ToList(); Technically just the latter change is required – the former will make it even more bulletproof. This is necessary since if any entries adding to the MemoryCache will be shared amongst callers – so if one caller manipulates the List then … Read more