Scope of Cache

  • Thread starter Thread starter ThatsIT.net.au
  • Start date Start date
T

ThatsIT.net.au

There are a few different ways to use cache in Asp.net.

What I want to know is what is the scope of these cache methods. what I mean
by scope is are are they cached for the one user or not.

if I use System.Web.HttpRuntime.Cache am I caching for all users who come to
the site?
Can I set a expiry for System.Web.HttpRuntime.Cache?
Should I use Application("variable") or has this been superseded?



--
Dim Alan as ThatsIT.net.au.Staffmember
Alan = New ThatsIT.net.au.Staffmember
Alan.signature = "Thank You"
Dim you as NewsgroupReader
you = New NewsgroupReader
Response.Write Alan.signature.toString()
Response.Write you.getName()
__________________________________________
 
Hi
if I use System.Web.HttpRuntime.Cache am I caching for all users who come
to the site?

Yes, exactly. Cache is global.
Can I set a expiry for System.Web.HttpRuntime.Cache?

Yes, within Insert method when adding items to Cache
Should I use Application("variable") or has this been superseded?

Cache supersedes Application since it has callback functionality (in case of
expiration), cache item priority for memory handling etc. Cache is much more
versatile than Application.
 
Cache is available for the duration of the app domain life time, that is, for
the life time of the web application. Also, it is not per-user basis.
 
Hi,
What is the scope of these cache methods.
Scope is an application (AppDomain), so you can use it for all users of the
application (site).
if I use System.Web.HttpRuntime.Cache am I caching for all users who come
to the site?
For this only site - yes (the current application).
Can I set a expiry for System.Web.HttpRuntime.Cache?
Even priority:
http://msdn2.microsoft.com/en-us/library/system.web.caching.cache.add.aspx
Should I use Application("variable") or has this been superseded?
Cache has self-clearance and dependencies ability, Application doesn't have
it (more persisted). Select based upon these features.

Regards, Alex
[TechBlog] http://devkids.blogspot.com
 
ThatsIT.net.au said:
There are a few different ways to use cache in Asp.net.

Indeed there are!
What I want to know is what is the scope of these cache methods. what I
mean by scope is are are they cached for the one user or not.

Cache is a global object - like the application object, so its a shared
object. To use it for indivusdals you would need to be caching objects like
you would if you placed them in session - not a good idea really!
if I use System.Web.HttpRuntime.Cache am I caching for all users who come
to the site?

Yes - while that application is in memory
Can I set a expiry for System.Web.HttpRuntime.Cache?

Yes- refer to the docs at msdn
Should I use Application("variable") or has this been superseded?

You can - cache is more flexible, but app is still available and still very
useful really! Your choice!

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
 
Back
Top