cache question

M

Mike P

I've read a couple of articles on cache and setting expiration etc.
What I can't find the answer to is - if you don't set an expiration for
your cache, what is the default? And when your cache does expire, how
do you catch this event? For example, if I have a datagrid which is
populated by cached data and the cached data expires, what happens when
I try to access that datagrid?


Any help would be much appreciated.


Cheers,

Mike
 
P

PJ

the cache will expire when the aspnet_wp is forced to recycle

when accessing cache data do something like this in a static method to
retrieve the data

string myCachedData = HttpContext.Current.WebCache("myCachedData");
if ( myCachedData == null )
{
// code to put the data in the cache
}
return myCachedData;
 
R

Ryan Gregg

It is recycled when
a) an application level error occurs
b) the server is restarted (or IIS is restarted)
c) an application times out, meaning it hasn't been accessed in the time
out period
d) in IIS 6.0 all applications are recycled on a set time period (set in
the IIS manager). I beleive the default is 29 hours.
e) If you recompile the application, when ASP.NET notices the change, it
recycles the application


Ryan Gregg
 
M

Mike P

So assigning something to the Cache is essentially the same as assigning
it to a Session variable (i.e. it expires on timeout and is particular
to the specific user and not the application)?


Mike
 
M

Mike P

I've done a few tests and found that Cache is Application level and not
Session level, which I would think means that it can only be used for
storing global variables.


Mike
 

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

Top