可以使用温莎城堡在内存中保留静态引用吗?

发布于 2024-11-13 07:47:43 字数 447 浏览 6 评论 0原文

背景... 我必须构建一个新的(asp.net mvc)应用程序,该应用程序使用一个复杂且现阶段无法重写的现有类库。主要问题是这个类库有一个巨大的初始化命中 - 需要长达 10 分钟的时间才能将所有数据加载到内存中。这对于生产环境来说是很好的,因为它在 IIS 启动后执行速度很快。然而,对于开发来说,这是一场噩梦,因为每次构建解决方案并在浏览器中启动它时,都需要很长时间。

可能的解决方案? 因此,我们的想法是可以使用 Castle Windsor 或 IOC 生活方式将其保存在内存中,这样只有回收应用程序池才会强制执行昂贵的重新加载。我记得以前当 Windsor 将代码保存在内存中时遇到问题,因此即使在更改代码并重新编译之后,IIS 仍然运行旧代码 - 在这种情况下这是一个问题,但在我的新情况下这正是我想要的。

有人知道如何做到这一点吗?我尝试过使用 Singleton 生活方式的虚拟项目,但在更改 mvc 项目后,它仍然重新加载类库。

Background...
I have to build a new (asp.net mvc) app that uses an existing class library that is complex and can't be rewritten at this stage. The main problem is that this class library has a huge initialisation hit - it takes up to 10 mins to load all its data into memory. This is fine for production environment where it performs fast after IIS has started up. However, for development this is a nightmare because every time you build the solution and start it up in a browser, it takes ages.

Possible Solution?
So, the idea was that Castle Windsor or IOC lifestyle can be used to hold this in memory so that only recycling the application pool will force an expensive reload. I remember having a problem before when Windsor was keeping code in memory so even after changing it and recompiling, IIS still had the old code running - in this scenario it was a problem, but in my new scenario this is exactly what I'd like.

Anyone know how this can be done? I have tried with a dummy project using Singleton lifestyle but after changing the mvc project it still reloads the class library.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感情废物 2024-11-20 07:47:43

如果数据确实序列化,那么您可以将其存储在缓存中,以便在重新编译时保持其状态。例如,memcached 作为单独的进程运行。您可以更改 bin 或重新启动开发服务器进程,缓存将保持其状态。 codeplex 上有一个用于访问 memcacheD 的提供程序。

If the data does serialize then you could store in a cache that will keep it's state when you recompile. For example, memcached runs as a separate process. You could change the bin or restart the dev server process and the cache will keep it's state. There's a provider for accessing memcacheD on codeplex.

久而酒知 2024-11-20 07:47:43

也许您可以序列化加载的库的内容并将其二进制形式保存在磁盘上。这可能会加快加载速度。这是一个疯狂的想法,但话又说回来,拥有一个需要 10 分钟才能加载的类库也是疯狂的。

Maybe you could serialize the contents of the loaded library and save it binary form on the disk. This could potentially speed up the load. It's a crazy idea, but then again, having a class library that takes 10 minutes to load is crazy, too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文