title: Does C#/.Net MemoryCache class need to serialize/deserialize objects
body: <p>In caching systems such as Redis/MemCache one needs to serialize and deserialize objects. When storing objects, one serializes, and when accessing that object one needs to deserialize. </p>
  
  <p>Does C#/.Net MemCache also need to serialize/desrialize objects? e.g. when I store an object of the following class, is only the object reference set in cache, OR the object is serialized before storing in Cache? Tests suggest that the cache is storing just a reference. But I wanted to check. </p>
  
  <pre><code>class CacheData
  {
      public int A = 0;
      public int B = 0;
  }
  
  private static void TestMemoryCache()
  {
      CacheData origObject = new CacheData();
      ObjectCache cache = MemoryCache.Default;
      CacheItemPolicy policy = new CacheItemPolicy();
      cache.Set("someKey", origObject, policy);
      origObject.A = 2;
      origObject.B = 3;
      CacheData cachedObj = cache["someKey"] as CacheData;
  
      if (cachedObj == origObject)
          Console.WriteLine("Same");
      else
          Console.WriteLine("Distinct");
  
      cachedObj.A = 5555;
  
      cachedObj = cache["someKey"] as CacheData;
      Console.WriteLine("The A value is: " + cachedObj.A);
  
  
  }
  </code></pre>