How to store objects in different areas in Asp.net 2.0

ask you for some help.

I have a web application running on Net 2.0.
I want to ask what storage (cache, session, file) should I use for my objects as they have different uses. It can be divided into several groups:
1) objects directly related to the visitor (for example, information about the visitor obtained after authentication)
2) objects that are used for each visitor, therefore its scope (some initialization data, general data)

Most of these entities get their data from a web service, which is expensive.

So what's my best bet considering speed, memory, accessibility and what else should I be looking at.

Any help is appreciated. Thank you, X.

0


source to share


3 answers


  • Objects directly related to the visitor should be stored in Session

    , although overuse Session

    and many users can lead to scalability issues.

  • The objects that are used for each visitor need to be stored in Cache

    so they go out of scope if they are often not available so that memory can be reclaimed (not to mention the added dependency incentive) In scenarios where you know that an object should be available immediately, no matter how much time elapsed between the last one it was accessed, you should save that object in Application

    .



+2


source


Point 1 - Session will most likely be the best as for the user, however remember to limit the number of items there as there are scaling issues and considerations if in a web farm.

Item 2 - whichever you want, it will be the cache or app tier item you want to add, depending on the need to expire, etc. The key difference is that there are expiration and use items in the cache that can remove it, the app is for things that always stay there.



In general, in a web application, I highly recommend AGAINST files as you have to worry about thread safety.

+1


source


Objects attributed to each visitor must be stored in the session. This is unique to each visitor, but tends to reset frequently, it also scales poorly when migrating to multiple server environments.

Objects related to the application as a whole must be stored in the ASP.NET cache.

0


source







All Articles