[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

means of viewing all Cached items?

SpaceMarine

10/7/2008 10:41:00 PM

hello,

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?


thanks!
sm
5 Answers

Alvin Bruney [ASP.NET MVP]

10/7/2008 11:58:00 PM

0

A tool to iterate the cache should be simple enough, not sure how you would
go about getting the memory allocation portion though. Maybe someone else
can chime in.

--
Regards,
Alvin Bruney

Want a free copy of VS 2008 w/ MSDN premium subscription?
Details at http://msmvps.com/blogs/alvin/De...

Auther Plug
OWC Blackbook now on download at www.lulu.com/owc

"SpaceMarine" <spacemarine@mailinator.com> wrote in message
news:d81a7816-690e-484f-9349-a15b09004450@l76g2000hse.googlegroups.com...
> hello,
>
> 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?
>
>
> thanks!
> sm

hcurrie

11/10/2008 2:49:00 PM

0


>A tool to iterate the cache should be simple enough,

Here's what I use to populate a list box with the cache keys:

With HttpRuntime.Cache

' display the number of items
TextBoxCacheSize.Text = CStr(.Count)

' clear the listbox
ListBoxCacheItems.Items.Clear()

' add the cache items
With .GetEnumerator()
While .MoveNext()
ListBoxCacheItems.Items.Add(.Key)
End While
End With

End With

> not sure how you would go about getting the memory allocation portion
> though.

I tried Len(.Value) which I thought should get the size of each item, but I
always get a Type Mismatch error.
I don't think the Len function works correctly for object types. If you only
stored simple generic type variables in the cache this might work though.


SpaceMarine

11/13/2008 5:30:00 PM

0

On Nov 10, 8:49 am, "Phil" <N/A> wrote:
> > not sure how you would go about getting the memory allocation portion
> > though.
>
> I tried Len(.Value) which I thought should get the size of each item, but I
> always get a Type Mismatch error.
> I don't think the Len function works correctly for object types. If you only
> stored simple generic type variables in the cache this might work though.

i store mostly DataTables -- the results of my commonly-used look-up
tables.

really wish there was a way to see how much RAM they consume on the
server....


thanks
sm

SpaceMarine

11/20/2008 8:37:00 PM

0

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

Paul Hale

1/9/2009 1:19:00 PM

0

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
>