开发者

Is using Castle Windsor singleton a valid approach for caching readonly data in ASP.NET

I have a .NET class that initialises some fixed readonly reference data. If I instantiate this class as a Singleton in开发者_Go百科 Castle Windsor in ASP.NET then presumably all attempts to access this class by transient web calls will read from the single instance of the reference data in memory.

Is this a valid approach? Are there any downsides?


Definitely a valid approach.

Only downside as I see it is you need to make sure the class is re-entrant - it may be accessed by multiple threads concurrently.


ASP.NET has a pretty effective caching framework (https://msdn.microsoft.com/en-us/library/6hbbsfk6.aspx) which can do this for you, deal with expiry times, prioirtisation, can remove items from the cache when you're low on memory, etc.

As with everything, it depends on your use case - how much data you have, what form it takes, etc.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜