This text may sound that the cache state object is not so good to use

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

I read in a book and when I come to the Cache state the text say the
following.
"If the ASP.NET worker process has a high memory usage, the ASP.NET runtime
removes cache items according to their priority. Items with a lower priority
are removed first."

This text may sound that if you for example store some data in the Cache
state object it may have been removed when you need it because the ASP.NET
runtime need more memory.

The text also say that when you add items to the cache state object you can
define a method that should be invoked when the cache item is removed.
I mean how should I handle this when the ASP.NET runtime will remove the
data in the Cache.
Is the solution that when the method is called which mean that the ASP.NET
runtime need more memory I will have to add my data into the Cache object
again ?

//Tony
 
I read in a book and when I come to the Cache state the text say the
following.
"If the ASP.NET worker process has a high memory usage, the ASP.NET runtime
removes cache items according to their priority. Items with a lower priority
are removed first."

This text may sound that if you for example store some data in the Cache
state object it may have been removed when you need it because the ASP.NET
runtime need more memory.

The text also say that when you add items to the cache state object you can
define a method that should be invoked when the cache item is removed.
I mean how should I handle this when the ASP.NET runtime will remove the
data in the Cache.
Is the solution that when the method is called which mean that the ASP.NET
runtime need more memory I will have to add my data into the Cache object
again ?

That is the main benefit of using Cache instead of Application.

With Application you store in it and you remove from it. If you
run out of memory you have a problem.

With Cache you store in it and tell it how to handle low
memory situations.

So with Application the web app may restart with mini-disasters
following.

But with Cache it is handled gracefully. Some objects are removed
and the app continue running. Yes - it may hit performance a bit
by lowering cache hit rate, but that would happen with the
alternatives as well - you can simply not store 50 GB of data
in 25 GB of RAM.

Arne
 
Back
Top