views:

24

answers:

1

In an ASP.NET web app written in VB.NET, I need to load and store a large 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?

A: 

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.

orka
@orka - why would thread safety be a concern on a read only object?
InSane
@In-Sane, sorry i missed that. @Alfred you dont have to worry about thread safety if you are sure no update will be required (i dont mean to update the data in the hashtable) the private member at all.
orka