Why use the cache object?

  • Thread starter Thread starter Guest
  • Start date Start date
vbMental said:
Why not just create a class level variable in the global.asax
code-behind page?

Here are a couple of reasons I gave in response to a similar question
some weeks ago:

-- The Cache is thread-safe (uses ReaderWriterLocks).

-- Cache entries can expire, can have scavenging priorities, can have
dependencies which may force them to be removed from the Cache, and the
Cache notifies you in case an entry is removed.

-- The Cache automatically scavenges entries if their lifetime has
expired or memory is low, thus is somewhat self-tuning.


Cheers,
 
Because the cache engine is optimised to work with cached objects, and can
interact directly with IIS's own caching elements to provide enhanced speed
improvements, at an object, fragment or page level..

It also has the advantage or automatically flushing based on criteria
changing, like the source of the cahced information (a file for example)
changing - you would have to code all of this around the access to your
global variable.
--
Regards

John

vbMental said:
Why not just create a class level variable in the global.asax code-behind
page?
 
Why not just create a class level variable in the global.asax code-behind

Heck, while we're at it, why bother with OOP, when procedural programming is
so much simpler!?

I'm going back to assembler!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
Back
Top