HighTechTalks DotNet Forums  

HttpRuntime.Cache

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss HttpRuntime.Cache in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Manso
 
Posts: n/a

Default HttpRuntime.Cache - 03-06-2006 , 07:10 AM






hi,

I'm experiencing a weird problem. I am using a TimerCallback in my ASP.NET
application. This callback function will access the cache and I'm using
HttpRuntime.Cache to intert an item to the cache with a file dependecy.

Every now and then the cache item requested is Null and I can't seem to work
out when it happens. Are there any limitation on HttpRuntime vs.
HttpContext.Current cache? We've been using HttpContext.Current for quite
some time without any problems but when switching to HttpRuntime the items
don't stick in the cache anymore.

Thanks,
Manso


Reply With Quote
  #2  
Old   
Alvin Bruney - ASP.NET MVP
 
Posts: n/a

Default Re: HttpRuntime.Cache - 03-06-2006 , 01:23 PM






the two both map to the same object. what most likely is happening is that
your cache is beign scavenged by the OS. There's no guarantee made by the
run-time that your cache objects will be available by the way so you should
not code with that assumption. Instead, you should test the cache before u
use it and replenish it as needed.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



"Manso" <Manso (AT) discussions (DOT) microsoft.com> wrote

Quote:
hi,

I'm experiencing a weird problem. I am using a TimerCallback in my ASP.NET
application. This callback function will access the cache and I'm using
HttpRuntime.Cache to intert an item to the cache with a file dependecy.

Every now and then the cache item requested is Null and I can't seem to
work
out when it happens. Are there any limitation on HttpRuntime vs.
HttpContext.Current cache? We've been using HttpContext.Current for quite
some time without any problems but when switching to HttpRuntime the items
don't stick in the cache anymore.

Thanks,
Manso




Reply With Quote
  #3  
Old   
Manso
 
Posts: n/a

Default Re: HttpRuntime.Cache - 03-06-2006 , 03:41 PM



Thanks for your reply.

There is a difference on how the two work. I have an isolated case where I
simply changed from HttpContext.Current.Cache to HttpRuntime.Cache with a
file dependency and the one with HttpRuntime gets reset. Not all the time but
sporadically. The code is located in a separate assembly being referenced
from a web project. When I change back it works well again.

Does anyone know how we can troubleshoot this? I'm starting to miss the old
VB function "Add watch and break when variable X changes"...

Thanks,
Manso
"Alvin Bruney - ASP.NET MVP" wrote:

Quote:
the two both map to the same object. what most likely is happening is that
your cache is beign scavenged by the OS. There's no guarantee made by the
run-time that your cache objects will be available by the way so you should
not code with that assumption. Instead, you should test the cache before u
use it and replenish it as needed.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



"Manso" <Manso (AT) discussions (DOT) microsoft.com> wrote in message
news:73ECAD89-357C-4D77-8D7F-6076EDA40C5E (AT) microsoft (DOT) com...
hi,

I'm experiencing a weird problem. I am using a TimerCallback in my ASP.NET
application. This callback function will access the cache and I'm using
HttpRuntime.Cache to intert an item to the cache with a file dependecy.

Every now and then the cache item requested is Null and I can't seem to
work
out when it happens. Are there any limitation on HttpRuntime vs.
HttpContext.Current cache? We've been using HttpContext.Current for quite
some time without any problems but when switching to HttpRuntime the items
don't stick in the cache anymore.

Thanks,
Manso





Reply With Quote
  #4  
Old   
Alvin Bruney - ASP.NET MVP
 
Posts: n/a

Default Re: HttpRuntime.Cache - 03-06-2006 , 04:26 PM



Quote:
Does anyone know how we can troubleshoot this? I'm starting to miss the
old
VB function "Add watch and break when variable X changes"...

You shouldn't. .NET has more powerful monitoring tools. One simple approach
is to set a conditional breakpoint on th value of the cache object. Another
approach is to set the break on all exceptions. If you can reproduce this at
will, i'd be interested in looking at some code.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



"Manso" <Manso (AT) discussions (DOT) microsoft.com> wrote

Quote:
Thanks for your reply.

There is a difference on how the two work. I have an isolated case where I
simply changed from HttpContext.Current.Cache to HttpRuntime.Cache with a
file dependency and the one with HttpRuntime gets reset. Not all the time
but
sporadically. The code is located in a separate assembly being referenced
from a web project. When I change back it works well again.

Does anyone know how we can troubleshoot this? I'm starting to miss the
old
VB function "Add watch and break when variable X changes"...

Thanks,
Manso
"Alvin Bruney - ASP.NET MVP" wrote:

the two both map to the same object. what most likely is happening is
that
your cache is beign scavenged by the OS. There's no guarantee made by
the
run-time that your cache objects will be available by the way so you
should
not code with that assumption. Instead, you should test the cache before
u
use it and replenish it as needed.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



"Manso" <Manso (AT) discussions (DOT) microsoft.com> wrote in message
news:73ECAD89-357C-4D77-8D7F-6076EDA40C5E (AT) microsoft (DOT) com...
hi,

I'm experiencing a weird problem. I am using a TimerCallback in my
ASP.NET
application. This callback function will access the cache and I'm
using
HttpRuntime.Cache to intert an item to the cache with a file
dependecy.

Every now and then the cache item requested is Null and I can't seem
to
work
out when it happens. Are there any limitation on HttpRuntime vs.
HttpContext.Current cache? We've been using HttpContext.Current for
quite
some time without any problems but when switching to HttpRuntime the
items
don't stick in the cache anymore.

Thanks,
Manso







Reply With Quote
  #5  
Old   
Manso
 
Posts: n/a

Default Re: HttpRuntime.Cache - 03-06-2006 , 04:40 PM



I posted this on a separate thread becuase it's not related to HttpRuntime

http://msdn.microsoft.com/newsgroups...d95&sloc=en-us

Thanks for your help.

- Manso

"Alvin Bruney - ASP.NET MVP" wrote:

Quote:
Does anyone know how we can troubleshoot this? I'm starting to miss the
old
VB function "Add watch and break when variable X changes"...


You shouldn't. .NET has more powerful monitoring tools. One simple approach
is to set a conditional breakpoint on th value of the cache object. Another
approach is to set the break on all exceptions. If you can reproduce this at
will, i'd be interested in looking at some code.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



"Manso" <Manso (AT) discussions (DOT) microsoft.com> wrote in message
news:42F9955B-DCD7-4807-9C53-A276A58302B6 (AT) microsoft (DOT) com...
Thanks for your reply.

There is a difference on how the two work. I have an isolated case where I
simply changed from HttpContext.Current.Cache to HttpRuntime.Cache with a
file dependency and the one with HttpRuntime gets reset. Not all the time
but
sporadically. The code is located in a separate assembly being referenced
from a web project. When I change back it works well again.

Does anyone know how we can troubleshoot this? I'm starting to miss the
old
VB function "Add watch and break when variable X changes"...

Thanks,
Manso
"Alvin Bruney - ASP.NET MVP" wrote:

the two both map to the same object. what most likely is happening is
that
your cache is beign scavenged by the OS. There's no guarantee made by
the
run-time that your cache objects will be available by the way so you
should
not code with that assumption. Instead, you should test the cache before
u
use it and replenish it as needed.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



"Manso" <Manso (AT) discussions (DOT) microsoft.com> wrote in message
news:73ECAD89-357C-4D77-8D7F-6076EDA40C5E (AT) microsoft (DOT) com...
hi,

I'm experiencing a weird problem. I am using a TimerCallback in my
ASP.NET
application. This callback function will access the cache and I'm
using
HttpRuntime.Cache to intert an item to the cache with a file
dependecy.

Every now and then the cache item requested is Null and I can't seem
to
work
out when it happens. Are there any limitation on HttpRuntime vs.
HttpContext.Current cache? We've been using HttpContext.Current for
quite
some time without any problems but when switching to HttpRuntime the
items
don't stick in the cache anymore.

Thanks,
Manso








Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.