How to know the all the data in the cache of an Asp.Net Application

We all know about the use of caching in our application. With good use of cache we can increase the performance of the
application considerably since application does not have to process the stuff again and again. But if we use too much of
caching in the application, it can be problem. After all the data in the cache has to be stored in the memory and most of the
application have limited memory. And more so in case of shared hosting.
But how do you know how much amount of cache is being cached. This need to be calculated at the runtime to know the
 data in the cache. This can help individual understand the requirement of application and change the hardware (if required).
You can also remove some caching, if you cannot increase the hardware.


To find all the data in the cache based on the Key we can use the following code. 

foreach (DictionaryEntry de in this.Cache)
      {
          Response.Write(de.Key);

          Response.Write(" : ");
          Response.Write(de.Value);

          Response.Write("");

      }

You can also bind the data to a Gridview with two bound column for key and value. This will shows us the amount of data in the cache for indivi

Reactions

Post a Comment

0 Comments

Close Menu