Caching data

  • Thread starter Thread starter 3P
  • Start date Start date
3

3P

I want to cache readonly data at application start and have it in cache
till application stops/restarts.
I can use static fields, Cache object or Application object.
Which is best? I've read that Application is for compatibility with ASP
and shouldn't be used for caching.
 
As said Mark it won't make a huge difference. Else what matters is not what
is the best practice but *why* it is the best practice.

One advantage of the cache object i can think of, is that it allows also to
handle the lifetime (see
http://msdn.microsoft.com/en-us/library/system.web.caching.cache.aspx). In
your case it doesn't seem to matter so keep whatever is in use and works...
Hence perhaps this advice you saw...

In all cases it's likely better to hide this from your main app so that you
can change the implementation at will...
 
Practically, there is very little difference...



Where have you read that...?
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312607

ASP.NET includes application state primarily for compatibility with
classic ASP so that it is easier to migrate existing applications to
ASP.NET. It is recommended that you store data in static members of the
application class instead of in the Application object. This increases
performance because you can access a static variable faster than you can
access an item in the Application dictionary.
 
I have never, not even once, used the word "slower" anywhere in this
thread...

For the record, I said:

"Practically, there is very little difference..."
"There really is *no* appreciable difference"
"Negligible"
That's what I'm saying

I cited
"...you can access a static variable faster than you can access an item
in the Application dictionary."

And You said
Once again, not true.

It is slower but it's neglibible. But IT IS slower.
 
Back
Top