Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

global variable v/s cache

Status
Not open for further replies.

need2progm

Programmer
Dec 13, 2002
92
US
Could someone tell me the difference or why I should use one over the other?

I am using asp.NET (2.0) to do a rewrite of an application to be released March of next year. I am little confused why I should cache something verse just putting a populated DataTable as a global variable at app start.
 
it's actually a good question, i've always been told to(and have) stayed away from the global variable method, if i've updated my database, i'll reset my cache object to make sure i have the newest data in it..

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
When you cache something you can control when it is released and re-cached. So if you had a table that is updated nightly, you could retrieve that data, cache it for 1 day and then get it again tomorrow automatically. You can even release cached items if a file changes. Plus you can cache pages or controls by post/get parameters which increases the response from your server.

You don't get that functionality with global variables.

Hope this helps.

 
fwiw
Unlike data stored in the Application object, items stored in the Cache object can have a number of additional attributes applied to them, including an expiration policy, a priority, and one or more dependencies. These attributes form the substrate of the advanced Cache features such as the ability to remove least-used items, have items expire at a given time, and set logical connections between a group of items and disk files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top