开发者

Can Use Castle Windsor to Keep Static References In Memory?

开发者 https://www.devze.com 2023-03-09 20:31 出处:网络
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

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 开发者_JAVA技巧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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号