开发者

Use of module private member instead of Application or Cache object in ASP.NET project

开发者 https://www.devze.com 2023-01-14 14:19 出处:网络
In an ASP.NET web app written in VB.NET, I need to load and store a l开发者_运维技巧arge read-only hash table that is frequently accessed by the application. It only needs to be loaded once on applica

In an ASP.NET web app written in VB.NET, I need to load and store a l开发者_运维技巧arge read-only hash table that is frequently accessed by the application. It only needs to be loaded once on application start, is never updated and can be accessed by any session at any time.

If I load the hash table into a private member in a (global) module, a lookup to it takes one 20th of the time compared to storing the hash table in the Application or Cache object. Is there any reason why I should not do this, or should Application or Cache always be used to store in-memory objects in an ASP.NET web application?


Since they are thread-safe I would recommend you to use Application or Cache object (in your case application object is more convenient). Of course, you may choose to implement your own but consider thread-safety.

0

精彩评论

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