MVC3数据缓存技术 [英] MVC3 data caching techniques

查看:127
本文介绍了MVC3数据缓存技术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SQL查询(存储过程)需要大约8-10seconds结果显示在之前的​​WebGrid返回。什么是性能关于asp.net-MVC3 cacheing因此用户不必采取8-10sec命中每次加载数据(不优化查询)?

I have a sql query (stored proc) that takes about 8-10seconds to return before the results are displayed in a webgrid. What is best practice for performance regarding cacheing in asp.net-mvc3 so the user doesn't have to take that 8-10sec hit everytime to load that data (less optimizing the query)?

推荐答案

您可以使用MemoryCache类存放在一些关键的这个查询的结果。关键可能是查询审核规定的散列(如果你有这样的)。这里有一些导游在MSDN上的如何使用它。

You could use the MemoryCache class to store the result of this query under some key. The key could be the hash of the query criterias (if you have such). And here are some guides on MSDN on how to use it.

在实施考虑到了缓存熊,这个缓存默认存储在内存中。这意味着,如果你是一个web场中运行该应用程序可能更有趣的使用分布式缓存,以便共享农场的所有节点相同的缓存数据。这可以通过延伸来完成的<一href=\"http://msdn.microsoft.com/en-us/library/system.runtime.caching.objectcache.aspx\">ObjectCache类与一些分布式缓存解决方案。例如 memcached的是很受欢迎的一个,它有 .NET提供。另一种分布式缓存解决方案是的AppFabric

When implementing caching bear in mind that this cache is stored in memory by default. This means that if you are running this application in a web farm it might be more interesting to use a distributed cache so that all nodes of the farm share the same cached data. This could be done by extending the ObjectCache class with some distributed caching solution. For example memcached is a popular one and it has .NET provider. Another distributed caching solution is AppFabric.

这篇关于MVC3数据缓存技术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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