我应该将自定义 AppSettings web.config 数据放入 ApplicationState 中吗?
我的 web.config 文件中的 AppSettings 有一些自定义值。
这些值会根据每个请求进行检查。 (请忽略这可能是一件坏事/好事的事实..这超出了问题的范围)。
例如。
因此,如果每个请求都检查 web.config 文件中该键的值,那么将其放入应用程序缓存(例如通过 global.asax)而不是每个请求都检查该值是否明智?
我假设当我们从 AppSettings 读取值时,网站会物理读取 web.config 文件?或者当网站启动时这些信息也全部读入内存,并且对任何 appSettings 信息的所有引用都只是内存中读取..而不是磁盘 I/O 读取?
I've got some custom values in the AppSettings, in my web.config file.
These values get checked upon every Request. (Please ignore the fact that this might be a bad/good thing .. that's out of scope of the question).
eg.
So if every request checks the web.config file for the value of this key, would be be smart to put this into the Application cache (eg. via the global.asax) instead of checking this value EVERY request?
I'm assuming that when we read a value from the AppSettings, the website does a physical read of the web.config file? or is this information also all read into Memory when the website starts up and all references to any appSettings information is just an inmemory read .. not a disk I/O read?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WebConfig 已缓存。仅在网站的第一个请求时进行物理读取。所有其他请求都使用缓存数据。这就是为什么当您更改 web.config 文件并调用请求时,您的站点会有一点延迟,因为 web.config 中的信息正在被重新缓存。
The WebConfig is cached. Just at the first request of the website does a physical read. All the others requests use the cache data. This is why when you change the web.config file and call a request your site will have a little delay, because the information in web.config is being recached.
无需执行任何操作:
http: //weblogs.asp.net/stevewellens/archive/2011/01/15/web-config-is-cached.aspx
There's no need to do anything:
http://weblogs.asp.net/stevewellens/archive/2011/01/15/web-config-is-cached.aspx