Which is best to use: Cache object or static variables

I need to store big data in my website, but I'm not sure what is the best to use:

Cache objects

or

Store data in static variables on the main page?

Please advise.

0


a source to share


1 answer


Using a cache has the advantage that you do not store objects in memory that are no longer in use (for example, using sliding / absolute expiration).

Additionally, ASP.NET can remove objects from the cache when the available memory gets low (which makes memory available).



If you are sure you are going to use some data all the time, then another alternative (to static variables) would be to use the Application object . This is the same as the Session object, but its data is global (for all sessions):

Application["myData"] = someData;

      

+1


a source







All Articles