简体   繁体   中英

ASP.NET built-in cache (HttpContext.Cache) - is anyone using this stuff?

Developers who are looking to leverage a side cache from ASP.NET seem to have an embarassment of riches / choices these days:

  1. The built-in ASP.NET cache (HttpContext.Cache)
  2. AppFabric on-premise
  3. AppFabric Azure
  4. Redis Azure
  5. Other third-party

If you haven't heard, Microsoft announced the end of life for #2. That (plus the existence of #4) makes me wonder whether #3 is a good long-term bet. But my real question is about #1. I've been in the ASP community a long time & I seldom hear about (or see) corporate uses of the built-in cache. Maybe other developers know something I don't? It sucks?

My company is pursuing #5. We were thinking of abstracing away from the vendor's API, perhaps using an interface based on #1's semantics, but if #1 was a non-starter from day one, what would be the point? --Thanks, BGU

I recently (last year or so) used the built in cache in an intranet environment to store 13Mb of slowly changing (once a day) data. The benefits for me were... ease of use, reliability and, because the built in cache is part of IIS, there were no additional dependencies (eg routing/firewalls) so less to go wrong.

Is the built-in cache in common use now? I've no idea, I rarely used it before, or since. Nevertheless it works and seems likely to be around for the foreseeable future.

  1. ASP.Net Cache (actually HttpRuntime.Cache ) it is a fastest of all and prefer method, if you do not plan to host as Web Farm or Web Garden.

  2. Windows Server AppFabric - You can use this if you plan to host as Web Farm or Web Garden. It requires a lot of configuration; I personally prefer Redis Cache .

  3. AppFabric Cache is already retired in Azure. Next, Azure In-Role Cache will be also retired soon.

  4. Redis Cache - It is currently a recommended method, if you plan to host in Azure.

The bottom line is if it is a single instance, I'll definitely use HttpRuntime.Cache . However, I personally prefer Redis Cache for Web Farm or Web Garden.

Solution: ObjectCache is a Microsoft-provided abstraction over both MemoryCache and AppFabric. It should be used as the abstraction over third-party products, too, if loose coupling is desired. (And that is what we ended up doing.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM