The Cache object

M

Mikeon

Hello!

Is there a way to get to the Cache object in some other way than the
current contex?
I mean - the Cache is independant from the request so I would expect to
see some kind of Cache.Current property or something like
HttpContext.Current, but unfortunately I've been unable to find one.
When it could be usefull is for example a situation when I put some
task to be done every few minutes on the server - independent from the
requests comming in.
The way I do it now is to catch one of the Requests, get the Cache from
there and store the reference to it in some global/static variable.
 
K

Karl Seguin [MVP]

HttpRuntime.Cache

You might need to reference the System.Web assembly, but you can use it for
any type of application, including windows forms, console, web service...

Karl
 
M

Mikeon

Hello!

Yep, I'm already referencing it, but! What I need is a way to get the
Cache object without the Context object which is only available during
request processing which is not allways the case when some code on the
server runs as in my example with tasks running on the server every few
minutes. The importatnt part is that the tasks are run even if no one
uses my application i.e.: no one is requesting pages at the moment and
there is some Timer object stored in the Application state which fires
some tasks.
 
K

Karl Seguin [MVP]

Not sure if you read what I said, but you can use the HttpRuntime.Cache
which IS available even without a context..

Karl
 
J

Joerg Jooss

Thus wrote Mikeon,
Hello!

Is there a way to get to the Cache object in some other way than the
current contex?
I mean - the Cache is independant from the request so I would expect
to
see some kind of Cache.Current property or something like
HttpContext.Current, but unfortunately I've been unable to find one.
When it could be usefull is for example a situation when I put some
task to be done every few minutes on the server - independent from the
requests comming in.
The way I do it now is to catch one of the Requests, get the Cache
from
there and store the reference to it in some global/static variable.

You can also consider using the Caching Application Block in EL 2.0. The
API is similar to ASP.NET's Cache class.

Cheers,
 
M

Mikeon

Hello!

Oh! I've missed this first line of yours. Of course it is what I was
looking for.
Thank you!
 

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,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top