简体   繁体   English

如何确定ASP.Net缓存的总大小?

[英]How to determine total size of ASP.Net cache?

I'm using the ASP.net cache in a web project, and I'm writing a "status" page for it which shows the items in the cache, and as many statistics about the cache as I can find. 我在一个Web项目中使用ASP.net缓存,并且正在为其编写一个“状态”页面,其中显示了缓存中的项目以及可以找到的关于缓存的尽可能多的统计信息。 Is there any way that I can get the total size (in bytes) of the cached data? 有什么方法可以获取缓存数据的总大小(以字节为单位)? The size of each item would be even better. 每个项目的大小会更好。 I want to display this on a web page, so I don't think I can use a performance counter. 我想在网页上显示它,所以我认为我不能使用性能计数器。

I am looking at my performance monitor and under the ASP.NET Apps v2.0.50727 category I have the following cache related counters: 我正在查看性能监视器,在ASP.NET Apps v2.0.50727类别下,我具有以下与缓存相关的计数器:

Cache % Machine Memory Limit Used 缓存已使用的机器内存百分比限制

Cache % Process Memory Limit Used 已使用的高速缓存百分比进程内存限制

There are also a lot of other cache related metrics under this category. 此类别下还有许多其他与缓存相关的指标。

These should be able to get you the percentage, then if you can get the total allowed with Cache.EffectivePrivateBytesLimit or some other call you should be able to figure it out. 这些应该可以为您提供百分比,然后,如果您可以使用Cache.EffectivePrivateBytesLimit或其他一些调用来获得允许的总数,那么您应该可以弄清楚。 I do not have personal experience with these counters so you will have to do some research and testing to verify. 我没有这些计数器的个人经验,因此您将必须进行一些研究和测试以进行验证。

Here is a quick start article on reading from performance counters: http://quickstart.developerfusion.co.uk/quickstart/howto/doc/PCRead.aspx 这是有关从性能计数器读取内容的快速入门文章: http : //quickstart.developerfusion.co.uk/quickstart/howto/doc/PCRead.aspx

Have not tried it. 还没有尝试过。 But maybe you can use Cache Manager plug-in for ASP.NET . 但是也许您可以使用ASP.NET的Cache Manager插件 Or use it as example. 或以它为例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM