Caching data

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.
 
P

Patrice

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...
 
3

3P

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.
 
3

3P

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top