[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.caching

Why does ASP.NET release cache items before the expiration time?

Sam via DotNetMonster.com

11/14/2006 8:41:00 PM

I have Win2003 64bit server with 6 GB or RAM. Windows Task Manager displays
that:

* 0.5 GB are taken by IIS
* 2.0 GB - SQL Server and other applications
* 3 GB - System Cache
* 0.5 GB - available

So it seems like I have plenty of available RAM. However when I add small
data objects to the ASP.NET cache it almost immediately automatically deletes
them, although I set 10 mins experation time and use CacheItemPriority.High.

What could be wrong? The same code works fine on my WindowsXP with 750MB of
RAM.

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-cachin...

3 Answers

offwhite

11/18/2006 6:18:00 PM

0

Sergey,

You can configure how much space your cache use. Perhaps the default
is not taking full advantage of all of your available memory.

Also, you can handle the Removed event on the Cache to handle an item
which is removed from the Cache. It provides a reason, and if it is
not expired you could toss it back into the Cache right away so that it
is available right away for the next request. What I have done is
fetch a fresh copy of the item (from a db in this case) and put it back
in the cache with a renewed expiration period. (see
CacheItemRemovedCallback)

You can find more info here.

http://msdn2.microsoft.com/en-gb/library/system.web.configuration.cachesection.percentagephysicalmemoryused...

http://msdn2.microsoft.com/en-us/library/system.web.caching.cacheitemremovedcal...

Brennan Stehling
http://brennan.off...

Sergey via DotNetMonster.com wrote:
> I have Win2003 64bit server with 6 GB or RAM. Windows Task Manager displays
> that:
>
> * 0.5 GB are taken by IIS
> * 2.0 GB - SQL Server and other applications
> * 3 GB - System Cache
> * 0.5 GB - available
>
> So it seems like I have plenty of available RAM. However when I add small
> data objects to the ASP.NET cache it almost immediately automatically deletes
> them, although I set 10 mins experation time and use CacheItemPriority.High.
>
> What could be wrong? The same code works fine on my WindowsXP with 750MB of
> RAM.
>
> --
> Message posted via DotNetMonster.com
> http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-cachin...

Sam via DotNetMonster.com

11/19/2006 7:41:00 PM

0

Brennan,

Thanks a lot for your suggestions. CacheItemRemovedCallback seems to be
exactly what I need in this case. I still do not understand why ASP.NET
clears cache when I have lots of free RAM, but I can live with this if I can
put objects back to the cache.

Sergey


offwhite wrote:
>Also, you can handle the Removed event on the Cache to handle an item
>which is removed from the Cache. It provides a reason, and if it is
>not expired you could toss it back into the Cache right away so that it
>is available right away for the next request. What I have done is
>fetch a fresh copy of the item (from a db in this case) and put it back
>in the cache with a renewed expiration period. (see
>CacheItemRemovedCallback)

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-cachin...

offwhite

11/19/2006 8:40:00 PM

0

Sergey,

You can set your cache item priority to make items stay in the cache
until their expiration. You will probably find the reason they are
removed is because the system thinks they are underused. By setting
the priority higher you can prevent them from being removed.

But do not make everything the highest priority otherwise you will
still have the same issue.

Brennan Stehling
http://brennan.offwhite...

Sergey via DotNetMonster.com wrote:
> Brennan,
>
> Thanks a lot for your suggestions. CacheItemRemovedCallback seems to be
> exactly what I need in this case. I still do not understand why ASP.NET
> clears cache when I have lots of free RAM, but I can live with this if I can
> put objects back to the cache.
>
> Sergey
>
>
> offwhite wrote:
> >Also, you can handle the Removed event on the Cache to handle an item
> >which is removed from the Cache. It provides a reason, and if it is
> >not expired you could toss it back into the Cache right away so that it
> >is available right away for the next request. What I have done is
> >fetch a fresh copy of the item (from a db in this case) and put it back
> >in the cache with a renewed expiration period. (see
> >CacheItemRemovedCallback)
>
> --
> Message posted via DotNetMonster.com
> http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-cachin...