Context.Cache

randy_belcher

Freshman
Joined
Dec 10, 2003
Messages
37
ok, there is a little more to this problem than the initial question. I have a web service that runs an intensive data query. It takes anywhere from 10 to 20 seconds to retrieve the results. A timer variable is held in the cache to make sure the query is only ran once every 30 seconds, no matter how many requests are made to the service. To keep everyone from waiting on the data. The data is also cached in memory. The wait problem occurs when a request comes in after the 30 seconds and the data needs required. My solution was to get the data on a separate thread. Another words, when the data needs required, start a thread to save the data in the cache, but go ahead and return the data that is currently in the cache to the requestee, so he doesn't see a big pause on his screen. The problem is, I never get any data, so I believe the thread is not completing or the data is not being saved in the cache correctly? Will the thread not complete if the service ends because the currently cached data is returned so quickly? Any help is appreciated. Thanks.

Randy

old question: Hello everybody! How can I access the Context.Cache in a class in my web service? Thanks.

Randy
 
Last edited:
Threads running under ASP.NET will either have to block the current request or they will be terminated as soon as the request is. In other words while your idea is a good one in theory, it simply will not work.

A solution for this would be to call an ansychronous Web method that returns immediately (which won't block the request for any extended period of time) or use the method linked to below.

http://authors.aspalliance.com/PaulWilson/Articles/?id=12

I like neither solution to be perfectly honest.
 
Thanks for the response Derek. Does the article also pertain to web services? Surely you don't need to keep a web service alive.
 
Last edited:
Back
Top