惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
Latest news
Latest news
Help Net Security
Help Net Security
S
Security Affairs
Webroot Blog
Webroot Blog
The Hacker News
The Hacker News
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tor Project blog
Forbes - Security
Forbes - Security
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Help Net Security
L
Lohrmann on Cybersecurity
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
MongoDB | Blog
MongoDB | Blog
Cyberwarzone
Cyberwarzone
The Last Watchdog
The Last Watchdog
S
Securelist
N
News and Events Feed by Topic
S
Secure Thoughts
F
Fortinet All Blogs
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
量子位
M
MIT News - Artificial intelligence
F
Full Disclosure
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
P
Privacy International News Feed
L
LangChain Blog
Know Your Adversary
Know Your Adversary
C
CERT Recently Published Vulnerability Notes

博客园 - 徘徊中的海鸟

在Dictionary使用foreach的注意 ADO.NET,连接\连接池问题 - 徘徊中的海鸟 - 博客园 关于sql server占用系统资源的问题 ASP.NET 的内存不足问题 SQL拆分字段 生成代码自动加入到解决方案中 SQL Server 2005数据库日志文件损坏的情况下如何恢复数据库 .net 发现的cache 问题 .NET线程若干问题 IIS 6.0中配置HTTP Gzip压缩 pre标签自动换行方案 HttpWebRequest 和 浏览器打开的区别 TestDirector 安装、使用心得 连接数问题 w3wp 进程问题 关于CultureInfo 读取树数据SQL 提高sql的效率 SQL中只获取日期值
HttpContext.Cache 和 HttpRuntime.Cache
徘徊中的海鸟 · 2007-09-06 · via 博客园 - 徘徊中的海鸟

首先先看看MSDN上对HttpContextHttpRuntime 的定义,

  1. HttpContext:   封装有关个别 HTTP 请求的所有 HTTP 特定的信息。
  2. HttpRuntime:  为当前应用程序提供一组 ASP.NET 运行时服务

        从定义看一个是针对一个特定的请求的,一个是对应整个ASP.NET应用程序而言.再看看HttpContext.Cache对象和HttpRuntime.Cache对象的定义:

  1. HttpContext.Cache:  为当前 HTTP 请求获取 Cache 对象。
  2. HttpRuntime.Cache: 获取当前应用程序的 Cache。       

   这里获取的Cache会不会一个是针对个人,一个是针对应用程序的呢? 实际情况不是的,无论是HttpContext.Cache 还是 HttpRuntime.Cache实际上调用的都是同一个Cache对象.其实从MSDN中对System.Web.Caching.Cache的说明也可以看出"对于每个应用程序域均创建该类的一个实例,并且只要对应的应用程序域保持活动,该实例便保持有效。",从"应用程序域"这里我们似乎可以猜测可能HttpContext.Cache仅仅就是调用了HttpRuntime.Cache而已,而且这样可以保持HttpContext.Cache和HttpRuntime.Cache的一致性.查看一下HttpContext.Cache 和 HttpRuntime.Cache的实现代码(如下):

  1. HttpContext.Cache
    public Cache Cache{      get      {            return HttpRuntime.Cache;      }}
  2. HttpRuntime.Cache
        
    public static Cache Cache{      get      {            return HttpRuntime._theRuntime._cache.CachePublic;      }} 
这里可以清楚的看到, HttpContext.Cache 和 HttpRuntime.Cache 实际上调用的是同一个Cache了.