简体   繁体   English

.Net Web应用程序使用的最佳缓存机制是什么?

[英]What's the best caching mechanism to use for .Net web applications?

What caching mechanism should I use for a .Net web application? .Net Web应用程序应使用哪种缓存机制? Memcached seems to be the best for the LAMP stack and Linux in general, but I'm not so sure that it's the answer for a .Net web application running on Windows. 一般而言,Memcached似乎是最适合LAMP堆栈和Linux的,但我不确定它是否是Windows上运行的.Net Web应用程序的答案。 My requirements are that it be distributed and that it run on Windows. 我的要求是将其分发并在Windows上运行。

There isn't a distributed caching system as mature as memcached for Windows, but Velocity is the distributed caching system being built by Microsoft and has a beta version available for download. 对于Windows,没有像memcached那样成熟的分布式缓存系统,但是Velocity是由Microsoft构建的分布式缓存系统,并且具有可供下载的beta版本。

Though what I've seen a lot of people do is run memcached on Linux, and use one of the .NET clients for memcached in their ASP.net code. 尽管我见过很多人在Linux上运行memcached,并在ASP.net代码中使用其中一个.NET客户端进行memcached。

Check out ScaleOut StateServer - it was primarily developed to provide high performance, out-of-process, distributed session management in a web farm scenario, but it is for general-purpose caching as well. ScaleOut StateServer-它主要是为了在Web服务器场方案中提供高性能,进程外,分布式会话管理而开发的,但它也适用于通用缓存。

It is a mature product too - but it ain't free. 它也是一种成熟的产品-但它不是免费的。 The main benefit is it was designed specifically to work with the ASP.NET / Windows stack. 主要优点是它是专门为与ASP.NET/Windows堆栈一起使用而设计的。

ASP.NET offers two caching strategies out of the box, application caching and page output caching. ASP.NET提供了两种开箱即用的缓存策略,即应用程序缓存和页面输出缓存。 For more information please see ASP.NET Caching Overview : 有关更多信息,请参见ASP.NET缓存概述

Often an application can increase performance by storing in memory data that is accessed frequently and that requires significant processing time to create. 通常,应用程序可以通过将经常访问且需要大量处理时间才能创建的数据存储在内存中来提高性能。 For example, if your application processes large amounts of data using complex logic and then returns the data as a report accessed frequently by users, it is efficient to avoid recreating the report every time a user requests it. 例如,如果您的应用程序使用复杂的逻辑处理大量数据,然后将数据作为用户经常访问的报告返回,则避免每次用户请求时都重新创建报告是有效的。 Similarly, if your application includes a page that processes complex data but that is updated only infrequently, it is inefficient for the server to recreate that page on every request. 同样,如果您的应用程序包含一个处理复杂数据的页面,但是该页面很少被更新,则服务器在每次请求时重新创建该页面都是无效的。

To help you increase application performance in these situations, ASP.NET provides caching using two basic caching mechanisms. 为了帮助您在这些情况下提高应用程序性能,ASP.NET使用两种基本的缓存机制提供缓存。 The first is application caching , which allows you to cache data you generate, such as a DataSet or a custom report business object. 第一个是应用程序缓存 ,它允许您缓存生成的数据,例如DataSet或自定义报表业务对象。 The second is page output caching , which saves the output of page processing and reuses the output instead of re-processing the page when a user requests the page again. 第二个是页面输出缓存 ,它保存页面处理的输出并在用户再次请求页面时重用输出,而不是重新处理页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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