Caching using HTTPContext

  • Thread starter Thread starter kplkumar
  • Start date Start date
K

kplkumar

This is the scenario. The flow of control goes from

WebService --> OurManager --> Persistence --> Database

also OurManager spwans a thread to execute the EmailSubsystem. This
system ues the persistence to retrive some information from the
database as well.

Our persistence layer depends on the HTTPContext for caching.
So when I try to spawn a thread from OurManager subsystem to execute
the EmailSubsystem, which collects some information from the database
and sends out email, our Persistence fails.

I want to know if there is someway that we can cache our objects
irrespective of the HTTPContext thread of execution, so that the cache
can be accessed from any other subsystem.

I hope I conveyed my idea well. Your help would be appreciated. Thanks.
 
The HttpContext is thread specific (understandably so, even). Because
of this, you need to pass the HttpContext along to your thread.

However, I would not recommend accessing the Response, and writing to
anything, and you might have to provide thread-safe access to the members,
as I don't believe that the context, or the cache, request, response, etc,
etc are thread-safe either.

Hope this helps.
 
One thing you might try, assuming that your "other subsystems" are running in
the same AppDomain the HTTPContext is running in, is to use the AppDomain
Cache:

System.AppDomain.CurrentDomain.SetData
and
System.AppDomain.CurrentDomain.GetData

So when your HttpContext comes in you would store the data / objects
immediately in AppDoman Cache with a unique id.


Peter
 

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

Back
Top