File Coverage

blib/lib/MySQL/Util/Data/Cache.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package MySQL::Util::Data::Cache;
2              
3 4     4   168039 use Moose;
  4         471855  
  4         35  
4 4     4   30341 use namespace::autoclean;
  4         8038  
  4         31  
5 4     4   311 use warnings FATAL => 'all';
  4         9  
  4         832  
6              
7              
8             =head1 NAME
9              
10             MySQL::Util::Data::Cache - The great new MySQL::Util::Data::Cache!
11              
12             =head1 VERSION
13              
14             Version 0.01
15              
16             =cut
17              
18             our $VERSION = '0.01';
19              
20              
21             =head1 SYNOPSIS
22              
23             Quick summary of what the module does.
24              
25             Perhaps a little code snippet.
26              
27             use MySQL::Util::Data::Cache;
28              
29             my $foo = MySQL::Util::Data::Cache->new();
30             ...
31              
32             =head1 EXPORT
33              
34             A list of functions that can be exported. You can delete this section
35             if you don't export anything, such as for a purely object-oriented module.
36              
37             =head1 SUBROUTINES/METHODS
38              
39             =head2 function1
40              
41             =cut
42              
43             #
44             # the main purpose of this class is to capture cache hits
45             # to ensure the cache is working properly
46             #
47              
48             has 'data' => (
49             is => 'rw',
50             required => 1,
51             default => sub { [] }
52             );
53              
54             before 'data' => sub {
55             my $self = shift;
56             if ( !scalar(@_) ) { $self->hits( $self->hits() + 1 ) } # cache hit
57             };
58              
59             has 'hits' => (
60             is => 'rw',
61             isa => 'Int',
62             required => 0,
63             default => 0
64             );
65              
66              
67             =head1 AUTHOR
68              
69             John Gravatt, C<< <john at gravatt.org> >>
70              
71             =head1 BUGS
72              
73             Please report any bugs or feature requests to C<bug-mysql-util-data-cache at rt.cpan.org>, or through
74             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MySQL-Util-Data-Cache>. I will be notified, and then you'll
75             automatically be notified of progress on your bug as I make changes.
76              
77              
78              
79              
80             =head1 SUPPORT
81              
82             You can find documentation for this module with the perldoc command.
83              
84             perldoc MySQL::Util::Data::Cache
85              
86              
87             You can also look for information at:
88              
89             =over 4
90              
91             =item * RT: CPAN's request tracker (report bugs here)
92              
93             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=MySQL-Util-Data-Cache>
94              
95             =item * AnnoCPAN: Annotated CPAN documentation
96              
97             L<http://annocpan.org/dist/MySQL-Util-Data-Cache>
98              
99             =item * CPAN Ratings
100              
101             L<http://cpanratings.perl.org/d/MySQL-Util-Data-Cache>
102              
103             =item * Search CPAN
104              
105             L<http://search.cpan.org/dist/MySQL-Util-Data-Cache/>
106              
107             =back
108              
109              
110             =head1 ACKNOWLEDGEMENTS
111              
112              
113             =head1 LICENSE AND COPYRIGHT
114              
115             Copyright 2013 John Gravatt.
116              
117             This program is free software; you can redistribute it and/or modify it
118             under the terms of the the Artistic License (2.0). You may obtain a
119             copy of the full license at:
120              
121             L<http://www.perlfoundation.org/artistic_license_2_0>
122              
123             Any use, modification, and distribution of the Standard or Modified
124             Versions is governed by this Artistic License. By using, modifying or
125             distributing the Package, you accept this license. Do not use, modify,
126             or distribute the Package, if you do not accept this license.
127              
128             If your Modified Version has been derived from a Modified Version made
129             by someone other than you, you are nevertheless required to ensure that
130             your Modified Version complies with the requirements of this license.
131              
132             This license does not grant you the right to use any trademark, service
133             mark, tradename, or logo of the Copyright Holder.
134              
135             This license includes the non-exclusive, worldwide, free-of-charge
136             patent license to make, have made, use, offer to sell, sell, import and
137             otherwise transfer the Package with respect to any patent claims
138             licensable by the Copyright Holder that are necessarily infringed by the
139             Package. If you institute patent litigation (including a cross-claim or
140             counterclaim) against any party alleging that the Package constitutes
141             direct or contributory patent infringement, then this Artistic License
142             to you shall terminate on the date that such litigation is filed.
143              
144             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
145             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
146             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
147             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
148             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
149             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
150             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
151             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
152              
153              
154             =cut
155              
156             __PACKAGE__->meta->make_immutable; # moose stuff
157              
158             1; # End of MySQL::Util::Data::Cache
159