views:

245

answers:

3

Hi guys, need ask you about some help.

I have web app running in Net 2.0.
I wanna ask what storage (cache, session, file) I should use for my objects as they have different scope of using. Can be divide into several groups:
1) objects related directly to visitor (e.g. details about visitor that are received after authentication)
2) objects that are used for every visitor, so its scope of application (some init data, common data)

Most of these objects get data from web service, which is expensive.

So what's my best choices considering speed, memory, accessibility and what else I should look out.

Any help most welcome. Thanks, X.

+1  A: 

Item 1 - Session would most likely be the best as it is per user, however, be sure to limit the number of items there as there are scaling issues, and considerations if in a web farm.

Item 2 - Depending on what you need, this would be a cache or application level item that you want to add, depending on need for expiration, etc. The key difference is cache has expiration and usage items that can remove it, application is for things that always stay there.

Overall, in a web application I strongly recommend AGAINST files as then you have to worry about thread saftey.

Mitchel Sellers
+2  A: 
  1. Objects related directly to the visitor should be stored in Session although excessive use of Session and many users can lead to scalability issues.

  2. Objects that are shared for every visitory should be stored in Cache so they will go out of scope if they aren't accessed often so that memory can be reclaimed (not to mention the added incentive of dependencies). In scenarios where you know an object must be accessible immediately no matter how much time has passed between the last time it was accessed, then you should store that object in Application.

cfeduke
A: 

Objects relative per visitor should be stored in Session. This is unique per visitor, but tends to be frequently flushed, this also scales poorly when you move to a multiple server environment.

Objects relative to the application as a whole should be stored in the ASP.NET Cache.

FlySwat
Flusing of session is highly dependent on the size of items in session, number of users on the system, and overall memory load.
Mitchel Sellers