I am using HttpContext.Current.Cache
to save objects into memory.
The code i have looks something like this:
public void Add(string key, object data, TimeSpan slidingExpirationTime)
{
HttpContext.Current.Cache.Insert(key, data, null, System.Web.Caching.Cache.NoAbsoluteExpiration, slidingExpirationTime);
}
public T Get<T>(string key)
{
T itemStored = (T)HttpContext.Current.Cache.Get(key);
if (itemStored == null)
itemStored = default(T);
return itemStored;
}
This works very fast!
I am curios how it's saving the object into memory.
Is it saving the pointer value, or is it hashing the object, then saving it into memory, and when i request it it deserializes it back?