I was wondering if the System.Runtime.Cache.MemoryCache marshals objects into a separate resource space, or if it resides in the same resource space as the calling object?
For instance, say I write a helper method, on some abstract object, that allows me to read and write objects (such as DataTables) to the cache:
public static void WriteCache(string KeyName, object Item, int ExpireMinutes = 30)
{
ObjectCache cache = MemoryCache.Default;
CacheItemPolicy policy = new CacheItemPolicy();
policy.SlidingExpiration = new TimeSpan(0, ExpireMinutes, 0);
policy.Priority = CacheItemPriority.Default;
cache.Add(new CacheItem(KeyName, Item), policy);
}
And then send a DataTable to the cache:
WriteCache("MY_DATA", dt, 15);
Would disposing the DataTable in the calling code, afterwards, also dispose the DataTable in the Cache? Or is the DataTables copied to the Cache (like a COM+ object, in Server Mode, when it marshals across to its resource space)?