Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > c575b3572b1a595b8b6ae0529951ea8a > files > 20

perl-CHI-0.44-3.fc14.noarch.rpm

<html><head><title>CHI::Stats</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >
<link rel="stylesheet" type="text/css" title="pod_stylesheet" href="http://search.cpan.org/s/style.css">

</head>
<body class='pod'>
<!--
  generated by Pod::Simple::HTML v3.15,
  using Pod::Simple::PullParser v3.15,
  under Perl v5.012002 at Wed Mar  2 00:52:11 2011 GMT.

 If you want to change this HTML document, you probably shouldn't do that
   by changing it directly.  Instead, see about changing the calling options
   to Pod::Simple::HTML, and/or subclassing Pod::Simple::HTML,
   then reconverting this document from the Pod source.
   When in doubt, email the author of Pod::Simple::HTML for advice.
   See 'perldoc Pod::Simple::HTML' for more info.

-->

<!-- start doc -->
<a name='___top' class='dummyTopAnchor' ></a>

<div class='indexgroup'>
<ul   class='indexList indexList1'>
  <li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
  <li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
  <li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
  <li class='indexItem indexItem1'><a href='#STATISTICS'>STATISTICS</a>
  <li class='indexItem indexItem1'><a href='#METHODS'>METHODS</a>
</ul>
</div>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>

<p>CHI::Stats - Record and report per-namespace cache statistics</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>

<pre>    # Turn on statistics collection
    CHI-&#62;stats-&#62;enable();

    # Perform cache operations

    # Flush statistics to logs
    CHI-&#62;stats-&#62;flush();

    ...

    # Parse logged statistics
    my $results = CHI-&#62;stats-&#62;parse_stats_logs($file1, ...);</pre>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>

<p>CHI can record statistics, such as number of hits, misses and sets, on a per-namespace basis and log the results to your <a href="http://search.cpan.org/perldoc?Log%3A%3AAny" class="podlinkpod"
>Log::Any</a> logger. You can then parse the logs to get a combined summary.</p>

<p>A single CHI::Stats object is maintained for each CHI root class, and tallies statistics over any number of CHI::Driver objects.</p>

<p>Statistics are reported when you call the <a href="#flush" class="podlinkpod"
>&#34;flush&#34;</a> method. You can choose to this once at process end, or on a periodic basis.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="STATISTICS"
>STATISTICS</a></h1>

<p>The following statistics are tracked:</p>

<ul>
<li>absent_misses - Number of gets that failed due to item not being in the cache</li>

<li>expired_misses - Number of gets that failed due to item expiring</li>

<li>get_errors - Number of caught runtime errors during gets</li>

<li>hits - Number of gets that succeeded</li>

<li>set_key_size - Number of bytes in set keys (divide by number of sets to get average)</li>

<li>set_value_size - Number of bytes in set values (divide by number of sets to get average)</li>

<li>sets - Number of sets</li>

<li>set_errors - Number of caught runtime errors during sets</li>
</ul>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="METHODS"
>METHODS</a></h1>

<dl>
<dt><a name="enable_=item_disable_=item_enabled"
>enable =item disable =item enabled</a></dt>

<dd>
<p>Enable, disable, and query the current enabled status.</p>

<p>When stats are enabled, each new cache object will collect statistics. Enabling and disabling does not affect existing cache objects. e.g.</p>

<pre>    my $cache1 = CHI-&#62;new(...);
    CHI-&#62;stats-&#62;enable();
    # $cache1 will not collect statistics
    my $cache2 = CHI-&#62;new(...);
    CHI-&#62;stats-&#62;disable();
    # $cache2 will continue to collect statistics</pre>

<dt><a name="flush"
>flush</a></dt>

<dd>
<p>Log all statistics to <a href="http://search.cpan.org/perldoc?Log%3A%3AAny" class="podlinkpod"
>Log::Any</a> (at Info level in the CHI::Stats category), then clear statistics from memory. There is one log message per cache label and namespace, looking like:</p>

<pre>    CHI stats: namespace=&#39;Foo&#39;; cache=&#39;File&#39;; start=20090102:12:53:05; end=20090102:12:58:05; absent_misses=10; expired_misses=20; hits=50; set_key_size=6; set_value_size=20; sets=30</pre>

<dt><a name="parse_stats_logs_(log1,_log2,_...)"
>parse_stats_logs (log1, log2, ...)</a></dt>

<dd>
<p>Parses logs output by CHI::Stats and returns a listref of stats totals by root class, cache label, and namespace. e.g.</p>

<pre>    [
     {root_class =&#62; &#39;CHI&#39;, cache =&#62;&#39;File&#39;, namespace =&#62; &#39;Foo&#39;, absent_misses =&#62; 100, expired_misses =&#62; 200, ... },
     {root_class =&#62; &#39;CHI&#39;, cache =&#62;&#39;File&#39;, namespace =&#62; &#39;Bar&#39;, ... },
    ]</pre>

<p>Lines with the root class, cache label, and namespace are summed together. Non-stats lines are ignored.</p>

<p>Each parameter to this method may be a filename or a reference to an open filehandle.</p>
</dd>
</dl>

<!-- end doc -->

</body></html>