HELP! With HttpRuntime.Cache

  • Thread starter Thread starter Bishop
  • Start date Start date
B

Bishop

I have googled to try and find an answer to this issue, but everything I
found
beats around the bush.

I have a web service that calls a DLL. In the DLL, I want to cache the small
table
data into server cache rather than hit the DB each time, since the data does
not
change for at least a day.

My question is, will this cache still be there when the web service is
invoked
again? Or does the cache only last as long as the web service (and DLL) is
instantiated?

Here is a snippet of the code:

try {
ds = (DataSet)HttpRuntime.Cache.Get("AVMPolicies");
} catch (Exception ex) {
strErrMsg += ex.Message;
throw new Exception(strErrMsg);
}
....
if (ds == null) {
//cache gone, get from DB
try {
//ORACLE
ds = OraRules.GetPoliciesDB();
//OTHER
//...
} catch (Exception ex) {
//bubbled
throw new Exception(ex.Message);
}
....
//store in cache
try {
HttpRuntime.Cache.Add("AVMPolicies",ds,null,DateTime.Now.AddMinutes(intTimeout),TimeSpan.Zero,CacheItemPriority.High,null);
} catch (Exception ex) {
strErrMsg += ex.Message;
throw new Exception(strErrMsg);
}
....
======================================================================
intTimeout is 15.

Thanks,
Bob
 
Bishop,

I hope that it is that the cache will only be there as long as the
Webservice is active. Otherwise by instance with testing we would get as
much caches as there are tests done.

However, this is of course another situation if you use your DLL in a
windowservice which you use in the webservice.

Just my thought,

Cor
 
Back
Top