HttpContext.Cache 和 HttpRuntime.Cache
来源:互联网 发布:mac air 是retina屏吗 编辑:程序博客网 时间:2024/04/30 05:46
首先先看看MSDN上对HttpContext 和 HttpRuntime 的定义,
- HttpContext: 封装有关个别 HTTP 请求的所有 HTTP 特定的信息。
- HttpRuntime: 为当前应用程序提供一组 ASP.NET 运行时服务
从定义看一个是针对一个特定的请求的,一个是对应整个ASP.NET应用程序而言.再看看HttpContext.Cache对象和HttpRuntime.Cache对象的定义:
- HttpContext.Cache: 获取当前应用程序的 Cache。
- HttpRuntime.Cache: 为当前 HTTP 请求获取 Cache 对象。
这里获取的Cache会不会一个是针对个人,一个是针对应用程序的呢? 实际情况不是的,无论是HttpContext.Cache 还是 HttpRuntime.Cache实际上调用的都是同一个Cache对象.其实从MSDN中对System.Web.Caching.Cache的说明也可以看出"对于每个应用程序域均创建该类的一个实例,并且只要对应的应用程序域保持活动,该实例便保持有效。",从"应用程序域"这里我们似乎可以猜测可能HttpContext.Cache仅仅就是调用了HttpRuntime.Cache而已,而且这样可以保持HttpContext.Cache和HttpRuntime.Cache的一致性.查看一下HttpContext.Cache 和 HttpRuntime.Cache的实现代码(如下):
- HttpContext.Cache
public Cache Cache{ get { return HttpRuntime.Cache; }}
-
HttpRuntime.Cache
public static Cache Cache{ get { return HttpRuntime._theRuntime._cache.CachePublic; }}
这里可以清楚的看到, HttpContext.Cache 和 HttpRuntime.Cache 实际上调用的是同一个Cache了.
- HttpContext.Cache和HttpRuntime.Cache
- HttpContext.Cache 和 HttpRuntime.Cache
- HttpContext.Cache和HttpRuntime.Cache
- HttpContext.Cache和HttpRuntime.Cache
- HttpContext.Cache和HttpRuntime.Cache
- HttpContext.Cache和HttpRuntime.Cache中的Cache
- HttpContext.Current.Cache 和 HttpRuntime.Cache
- HttpContext.Cache和HttpRuntime.Cache的区别
- HttpContext.Cache和HttpRuntime.Cache的区别
- HttpContext.Current.Cache 和 HttpRuntime.Cache
- HttpContext.Current.Cache 和 HttpRuntime.Cache
- HttpContext.Current.Cache 和HttpRuntime.Cache的区别
- HttpContext.Current.Cache 和HttpRuntime.Cache的区别
- HttpContext.Current.Cache 和HttpRuntime.Cache的区别
- HttpContext.Current.Cache和HttpRuntime.Cache的区别
- HttpRuntime.Cache vs. HttpContext.Current.Cache
- HttpRuntime.Cache vs. HttpContext.Current.Cache
- HttpRuntime.Cache vs. HttpContext.Current.Cache
- 一个c++写的发牌程序
- 软件开发重要思想的总结
- 软件开发重要思想的总结
- 软件开发重要思想的总结
- 软件开发重要思想的总结
- HttpContext.Cache 和 HttpRuntime.Cache
- FxCop 设计规则
- FTP客户端库文件C#源码 (有两篇,第三篇支持中文)
- Exceptional C++ Style之28
- LoadRunner中添加weblogic监视器(JMX)
- [转]基于反向代理的Web缓存加速 ——可缓存的CMS系统设计
- 代码注入(Inject your code to a Portable Executable file)
- IC设计高手的成长之路
- 关于线程的基本常识