httpruntime.cache

Sharing an HttpRuntime.Cache across two IIS applications

做~自己de王妃 提交于 2020-01-03 17:47:08
问题 I have two ASP.NET 2.0 applications in IIS; a public booking system and an admin system to manage prices. There is a shared DLL project that accesses the database, used by both applications. To improve performance, the prices are cached in DLL code to save hitting the database on every request. However, when the administrator changes the prices, the cache is refreshed on the admin application (and obviously it isn't refreshed on the public application) So, to the question. Is it possible to

What's the difference between the HttpRuntime Cache and the HttpContext Cache?

六眼飞鱼酱① 提交于 2019-12-31 09:17:29
问题 I know there is a very similar question here but I was hoping to get a better explination. Why would I ever use HttpContext.Cache instead of HttpRuntime.Cache if the HttpContext really uses the HttpRuntime.Cache behind the scenes? In the article Simulate a Windows Service using ASP.NET to run scheduled jobs Omar uses the HttpContext to store his cache items, but when Jeff Atwood Implemented it here he chose to use the HttpRuntime instead. Obviously in this particular situation it makes sense

What's the difference between the HttpRuntime Cache and the HttpContext Cache?

ぐ巨炮叔叔 提交于 2019-12-31 09:17:25
问题 I know there is a very similar question here but I was hoping to get a better explination. Why would I ever use HttpContext.Cache instead of HttpRuntime.Cache if the HttpContext really uses the HttpRuntime.Cache behind the scenes? In the article Simulate a Windows Service using ASP.NET to run scheduled jobs Omar uses the HttpContext to store his cache items, but when Jeff Atwood Implemented it here he chose to use the HttpRuntime instead. Obviously in this particular situation it makes sense

How to prevent HttpRuntime.Cache to remove items in ASP.NET 4.5?

有些话、适合烂在心里 提交于 2019-12-25 09:01:54
问题 This is a follow-up to this question, which contains contradictory answers. I am also interested in an answer related to a more recent version of ASP.NET. My application uses HttpRuntime.Cache to cache some lists of models that should never expire. They are loaded on application warmup and they are changed quite rarely, but read quite often. My code is the following: private void ReportRemovedCallback(string key, object value, CacheItemRemovedReason reason) { if (!ApplicationPoolService

Null as value in HttpRuntime.Cache.Add

独自空忆成欢 提交于 2019-12-23 10:57:32
问题 I want to store null for some of the keys in HttpRuntime.Cache as I dont want to again go to Database to find that there is no entry for that key. So first time, it goes to database and fills the cache. The intent is to serve the following calls using cached data instead of doing the database call. Here is the code that I am using the following: Info info = null; if (HttpRuntime.Cache["Info_" + id.ToString() + "_" + quantity.ToString()] != null) info = HttpRuntime.Cache["Info_" + id.ToString(

HttpRuntime.Cache[] vs Application[]

牧云@^-^@ 提交于 2019-12-18 11:46:25
问题 I know that most people recommend using HttpRuntime.Cache because it has more flexibility... etc. But what if you want the object to persist in the cache for the life of the application? Is there any big downside to using the Application[] object to cache things? 回答1: As long as you don't abuse the application state, then I don't see a problem in using it for items that you don't want to expire. Alternatively I would probably use a static variable near the code that uses it. That way you

Should I use HttpRuntime.Cache?

我的未来我决定 提交于 2019-12-17 23:01:17
问题 I'm a beginner in asp.net, and have a few question of Cache: HttpRuntime.Cache only provides severals methods and I think I'm able to implement these methods with Dictionary by myself. If HttpRuntime.Cache is much better than Dictionary, why some people would like to implement their own cache framework. How about MS Enterprise Cache Block? 回答1: HttpRuntime.Cache only provides severals methods and I think I'm able to implement these methods with Dictionary by myself. You think wrong.

ASP.NET: HttpRuntime.Cache getting flushed when saving WebConfigurationManager — Is this a bug?

倖福魔咒の 提交于 2019-12-11 08:49:32
问题 Recently, I've been experimenting with caching objects with HttpRuntime.Cache and I was generally under the impression that if I "added" something to the cache like this: HttpRuntime.Cache.Insert("Test", "This is a test!", null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(FileChanged)); that the "NotRemovable" and "NoExpiration" flags would keep the object in-memory for the duration of the application. But was finding

How can I get the size of an object in the HttpRuntime.Cache?

情到浓时终转凉″ 提交于 2019-12-10 14:10:45
问题 I am currently storing many different types of objects in the ASP.NET HttpRuntime.Cache and I was wondering if there is a way to figure out how big each object is? 回答1: Look at these questions: Getting the size of a field in bytes with C# Find out the size of a .net object In particular, look for Jon Skeet's answer in those questions. They will tell you why the number won't be accurate. As for getting an estimate, there is no way to do that unless there are certain criteria to be met for your

50GB HttpRuntime.Cache Persistence Possible?

こ雲淡風輕ζ 提交于 2019-12-04 14:23:07
问题 We have an ASP.NET 4.0 application that draws from a database a complex data structure that takes over 12 hours to push into an in memory data structure (that is later stored in HttpRuntime.Cache). The size of the data structure is quickly increasing and we can't continue waiting 12+ hours to get it into memory if the application restarts. This is a major issue if you want to change the web.config or any code in the web application that causes a restart - it means a long wait before the