缓存策略,输出缓存VS数据缓存或两者兼而有之? [英] Caching strategy, Output Cache vs Data Cache or both?

查看:116
本文介绍了缓存策略,输出缓存VS数据缓存或两者兼而有之?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个ASP.NET MVC项目,我来,我要开始考虑我的缓存策略的地步。我试着离开我的框架尽可能地开放在高速缓存使用。

I'm working on an ASP.NET MVC project and I've come to the point where I want to start considering my caching strategy. I've tried to leave my framework as open as possible for the use in caching.

从我斯科特Hanselman的播客StackOverflow.com时听到使用页面输出缓存和拉链的内容,并将其放入RAM。这听起来像这将是巨大的用户范围的缓存,但这样的事情个性​​化页面,你将不得不缓存为每个用户一个版本,并可能失控的速度非常快。

From what I heard during Scott Hanselman's podcast StackOverflow.com uses page output caching and zips that content and puts it into RAM. This sounds like this would be great for user-wide cache but for something like personalized pages you would have to cache a version for each user and that could get out of control very quickly.

因此​​,对于缓存策略。应该使用,输出缓存,数据缓存或组合?我的第一个想法都是,但据缓存依赖它听起来像它可能变得有点复杂。

So, for a caching strategy. Which should be used, Output Caching, Data Caching or combined? My first thoughts are both but as far as cache dependencies it sounds like it could get a bit complex.

推荐答案

要小心过分进取缓存。尽管缓存是帮助性能的工具,使用不当的时候,它实际上可以使性能变得更糟。

Be careful about over-aggressive caching. Although caching is a tool for helping performance, when used incorrectly, it can actually make performance worse.

我不能回答是否输出缓存或数据缓存会为你更好的工作,不知道你的项目的更多细节。
我可以提供帮助的时候使用一个比其他几个例子。

I can't answer whether output caching or data caching would work for you better without knowing more details about your project. I can help provide a couple examples of when to use one over another.

如果你有,你会在很多不同的意见经常使用一个特定的数据集,你会更好使用数据缓存。如果您的数据读取操作是很常见的和昂贵相对于你的数据呈现你会使用这个。如果你有哪些使用了相同数据的多个视图,您将节省您的数据读取时间。

If you have a specific data set which you would use often in many different views, you'd be better off using data caching. You'd use this if your data fetch operation was very common and expensive relative to your data rendering. If you had multiple views which used the same data, you would save your data fetching time.

如果你有它使用了非常具体的数据集和视图的渲染比较复杂,并要求这个观点是非常频繁(例如,堆栈溢出的主页)视图,那么你会受益匪浅的输出缓存。

If you had a view which used a very specific data set and the rendering of the view was complicated and this view was requested very often (for example, stack overflow's home page), then you would benefit a lot from output caching.

所以,最后,这真的取决于你的需求,并小心使用缓存不正确。

So in the end, it really depends on your needs and be careful about using caching incorrectly.

这篇关于缓存策略,输出缓存VS数据缓存或两者兼而有之?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆