简体   繁体   English

Web场环境中ASP.NET网站的数据缓存

[英]Data caching for an ASP.NET website in a web farm environment

I've done some searching and haven't found a specific answer. 我已经做了一些搜索,还没有找到具体的答案。 Anyhow, I was wondering how most medium sized ASP.NET based websites cache data so that they don't always have to database look ups for the same data on different pages when running on a web farm environment. 无论如何,我想知道大多数基于ASP.NET的中型网站如何缓存数据,以便在Web场环境中运行时,不必总是对不同页面上的相同数据进行数据库查找。 I'm aware that you can use a sql server cache, but to me, that defeats the whole purpose of the cache. 我知道您可以使用sql服务器缓存,但是对我来说,这违反了缓存的全部目的。 If I want to use a dedicated server to share cache (and even possible session data), what do most sites use for this? 如果我想使用专用服务器共享缓存(甚至可能的会话数据),那么大多数站点会使用什么? I've done searching and get a lot of 'guesses' when it comes to implementations, but it's really hard to believe that there isn't some standard way of doing this given that there are so many ASP.NET websites out there. 我已经进行了搜索,并获得了很多有关实现的“猜测”,但是,由于那里有太多的ASP.NET网站,所以很难相信没有标准的方法可以做到这一点。

I am aware of AppFabric that seems like it might do the trick, but only runs on Windows server 2008+ and we're currently using 2003. Also, I've checked out NCache but it seems to be a little pricey. 我知道AppFabric似乎可以解决问题,但只能在Windows Server 2008+上运行,并且我们当前使用的是2003。此外,我已经检查了NCache,但价格似乎有点高。

Has anyone implemented a solution that worked for them? 有没有人实施过适合他们的解决方案? Database lookups can be quite painfully slow when 1000+ users are hitting your site simultaneously. 当1000多个用户同时访问您的站点时,数据库查找可能会非常缓慢。

Thanks in advance! 提前致谢!

Might want to take a look at HttpContext.Cache and HttpRuntime.Cache 可能想看看HttpContext.CacheHttpRuntime.Cache

You can get your information from the database then create datasets (or dictionaries, or whatever you want) and then store those in cache to be referenced site wide. 您可以从数据库中获取信息,然后创建数据集(或字典,或所需的任何内容),然后将其存储在缓存中以供站点范围内的参考。

You can even specify how long you want the cache to persist. 您甚至可以指定希望缓存保留多长时间。 And when it expires the next request for that data will go to the database and recreate your cache. 并且当它过期时,对该数据的下一个请求将进入数据库并重新创建缓存。

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

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