File Coverage

blib/lib/Cache/Ref/GCLOCK.pm
Criterion Covered Total %
statement 3 5 60.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             package Cache::Ref::GCLOCK;
2             BEGIN {
3 1     1   2728 $Cache::Ref::GCLOCK::AUTHORITY = 'cpan:NUFFIN';
4             }
5             BEGIN {
6 1     1   20 $Cache::Ref::GCLOCK::VERSION = '0.05'; # TRIAL
7             }
8             # ABSTRACT: GCLOCK cache replacement algorithm
9              
10 1     1   686 use Moose;
  0            
  0            
11              
12             use namespace::autoclean;
13              
14             extends qw(Cache::Ref);
15              
16             with qw(Cache::Ref::CLOCK::Base);
17              
18             sub _hit {
19             my ( $self, $e ) = @_;
20              
21             $_->[0]++ for @$e;
22             }
23              
24             __PACKAGE__->meta->make_immutable;
25              
26             __PACKAGE__;
27              
28              
29             # ex: set sw=4 et:
30              
31              
32             __END__
33             =pod
34              
35             =encoding utf-8
36              
37             =head1 NAME
38              
39             Cache::Ref::GCLOCK - GCLOCK cache replacement algorithm
40              
41             =head1 SYNOPSIS
42              
43             my $c = Cache::Ref::GCLOCK->new(
44             size => $n,
45             );
46              
47             =head1 DESCRIPTION
48              
49             This algorithm is related to L<Cache::Ref::CLOCK> but instead of starting all
50             cache hits from C<k>, a counter is increased on every hit.
51              
52             This provides behavior which models an LFU expiry policy (without taking into
53             account the full keyspace).
54              
55             =head1 ATTRIBUTES
56              
57             =over 4
58              
59             =item size
60              
61             The size of the live entries.
62              
63             =back
64              
65             =head1 AUTHOR
66              
67             Yuval Kogman
68              
69             =head1 COPYRIGHT AND LICENSE
70              
71             This software is copyright (c) 2011 by Yuval Kogman.
72              
73             This is free software; you can redistribute it and/or modify it under
74             the same terms as the Perl 5 programming language system itself.
75              
76             =cut
77