简体   繁体   English

在asp.net中为两个子域缓存一个对象

[英]Cache an object for two subdomains in asp.net

We have just added a few more sub domains to our organisation's website. 我们刚刚在组织的网站中添加了一些子域。 One sub domain is now dedicated for admin things like editing pages and content, another one now handles the gallery and the main one is just responsible for displaying the normal website. 现在,一个子域专门用于管理诸如编辑页面和内容之类的子域,另一个子域现在用于管理画廊,而主子域仅负责显示正常的网站。 All in their own respective app pool. 全部位于各自的应用程序池中。

The problem is that, on the normal webpage, we have a lot of pages that load their content from the database. 问题是,在普通网页上,我们有很多页面可以从数据库中加载其内容。 This is fine in most cases but is starting to become a problem. 在大多数情况下,这很好,但开始成为问题。 My idea is to cache the content that is to be displayed on the webpages to avoid having it load from the database all the time. 我的想法是缓存要在网页上显示的内容,以避免一直将其从数据库中加载。 The problem is that if i create a cache on the webpage it's not shared with the other sub domains. 问题是,如果我在网页上创建缓存,则不会与其他子域共享。

What would be a good way to resolve this and have a cache that is shared between all our sub domains? 解决此问题并在所有子域之间共享缓存的最佳方法是什么? Create some sort of WCF/Console-project that is running in the background serving the cache? 创建某种在后台为缓存提供服务的WCF / Console-project? Create a Windows Service? 创建Windows服务?

Since we are an organisation we don't have that much money to go around with and so buying an expensive solution is not possible. 由于我们是一个组织,因此没有足够的资金,因此不可能购买昂贵的解决方案。

I think you could use Redis cache http://redis.io/ as your caching solution. 我认为您可以使用Redis缓存http://redis.io/作为缓存解决方案。 It can be run on the same server (or a dedicated one) and it is fast enough for most practical use cases. 它可以在同一台服务器(或专用服务器)上运行,并且对于大多数实际用例来说足够快。

All of your webapps can share the same instance of Redis cache and using a product already being used by a larger community is definitely better than reinventing your own cache unless you have a very specific need an existing solution can't fulfil. 您的所有Web应用程序都可以共享相同的Redis缓存实例,并且使用大型社区已经在使用的产品绝对比重新发明自己的缓存更好,除非您有非常特定的需求,而现有解决方案无法满足。

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

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