Paul Hale
1/9/2009 1:19:00 PM
This may be of use to someone.
A simple page that displays cached items that you have stored and an option
to remove each individule item. I use it when testing code...
(I would also like to know how much memory each item uses but have not
figured this out yet)
protected void Page_Load(object sender, EventArgs e)
{
// Remove cache if the Remove link has been clicked.
string strKeyToRemove = Request.QueryString["Remove"];
if (strKeyToRemove != null)
{
HttpContext.Current.Cache.Remove(strKeyToRemove);
}
System.Collections.IDictionaryEnumerator myEnumerator;
myEnumerator = Cache.GetEnumerator();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
while (myEnumerator.MoveNext())
{
if (myEnumerator.Key.ToString().EndsWith("_wpui"))
{
sb.Append("<br />Key: ");
sb.Append(myEnumerator.Key.ToString());
sb.Append(" Value: ");
sb.Append(myEnumerator.Value.ToString());
sb.Append(" <a href='ViewCache.aspx?remove=" +
myEnumerator.Key.ToString());
sb.Append("'>Remove</a>");
}
if (myEnumerator.Key.ToString().EndsWith("_authUserRunTimeData"))
{
sb.Append("<br />Key: ");
sb.Append(myEnumerator.Key.ToString());
sb.Append(" Value: ");
sb.Append(myEnumerator.Value.ToString());
sb.Append(" <a href='ViewCache.aspx?remove=" +
myEnumerator.Key.ToString());
sb.Append("'>Remove</a>");
}
}
lbOutput.Text = sb.ToString();
}
"SpaceMarine" wrote:
> On Oct 7, 4:40 pm, SpaceMarine <spacemar...@mailinator.com> wrote:
> > i am interesting in running a tool or page that allows me to see all
> > items deposited into my server's Cache object, and their size in
> > memory.
> >
> > is there a general way to do this?
>
> i found the closest thing to it -- Windows' Performance Monitors.
> there is a whole section dedicated to ASP.NET Apps, which include
> several metrics for the Cache API. using it, i can see running tallies
> for the number of Cache API items, as well as the "% Machine Memory
> Limit Used". when 100% is reached, half of the cached items are
> destroyed. (there are many other counters...cool)
>
>
> sm
>