【发布时间】:2013-02-22 17:36:47
【问题描述】:
我正在使用HttpContext.Current.Cache 将对象保存到内存中。
我的代码看起来像这样:
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;
}
这工作非常快!
我很好奇它是如何将对象保存到内存中的。
是保存指针值,还是对对象进行哈希处理,然后将其保存到内存中,当我请求它时,它会反序列化它?
【问题讨论】:
标签: asp.net asp.net-caching httpcontext.cache