1CHI::Stats(3)         User Contributed Perl Documentation        CHI::Stats(3)
2
3
4

NAME

6       CHI::Stats - Record and report per-namespace cache statistics
7

VERSION

9       version 0.44
10

SYNOPSIS

12           # Turn on statistics collection
13           CHI->stats->enable();
14
15           # Perform cache operations
16
17           # Flush statistics to logs
18           CHI->stats->flush();
19
20           ...
21
22           # Parse logged statistics
23           my $results = CHI->stats->parse_stats_logs($file1, ...);
24

DESCRIPTION

26       CHI can record statistics, such as number of hits, misses and sets, on
27       a per-namespace basis and log the results to your Log::Any logger.  You
28       can then parse the logs to get a combined summary.
29
30       A single CHI::Stats object is maintained for each CHI root class, and
31       tallies statistics over any number of CHI::Driver objects.
32
33       Statistics are reported when you call the "flush" method. You can
34       choose to this once at process end, or on a periodic basis.
35

STATISTICS

37       The following statistics are tracked:
38
39       ·   absent_misses - Number of gets that failed due to item not being in
40           the cache
41
42       ·   expired_misses - Number of gets that failed due to item expiring
43
44       ·   get_errors - Number of caught runtime errors during gets
45
46       ·   hits - Number of gets that succeeded
47
48       ·   set_key_size - Number of bytes in set keys (divide by number of
49           sets to get average)
50
51       ·   set_value_size - Number of bytes in set values (divide by number of
52           sets to get average)
53
54       ·   sets - Number of sets
55
56       ·   set_errors - Number of caught runtime errors during sets
57

METHODS

59       enable =item disable =item enabled
60           Enable, disable, and query the current enabled status.
61
62           When stats are enabled, each new cache object will collect
63           statistics. Enabling and disabling does not affect existing cache
64           objects. e.g.
65
66               my $cache1 = CHI->new(...);
67               CHI->stats->enable();
68               # $cache1 will not collect statistics
69               my $cache2 = CHI->new(...);
70               CHI->stats->disable();
71               # $cache2 will continue to collect statistics
72
73       flush
74           Log all statistics to Log::Any (at Info level in the CHI::Stats
75           category), then clear statistics from memory. There is one log
76           message per cache label and namespace, looking like:
77
78               CHI stats: namespace='Foo'; cache='File'; 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
79
80       parse_stats_logs (log1, log2, ...)
81           Parses logs output by CHI::Stats and returns a listref of stats
82           totals by root class, cache label, and namespace. e.g.
83
84               [
85                {root_class => 'CHI', cache =>'File', namespace => 'Foo', absent_misses => 100, expired_misses => 200, ... },
86                {root_class => 'CHI', cache =>'File', namespace => 'Bar', ... },
87               ]
88
89           Lines with the root class, cache label, and namespace are summed
90           together.  Non-stats lines are ignored.
91
92           Each parameter to this method may be a filename or a reference to
93           an open filehandle.
94

SEE ALSO

96       CHI
97

AUTHOR

99       Jonathan Swartz <swartz@pobox.com>
100
102       This software is copyright (c) 2011 by Jonathan Swartz.
103
104       This is free software; you can redistribute it and/or modify it under
105       the same terms as the Perl 5 programming language system itself.
106
107
108
109perl v5.12.3                      2011-03-17                     CHI::Stats(3)
Impressum