line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Cache::Null - Null implementation of the Cache interface |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Cache::Null; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $cache = Cache::Null->new(); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
See Cache for the usage synopsis. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
The Cache::Null class implements the Cache interface, but does not actually |
16
|
|
|
|
|
|
|
persist data. This is useful when developing and debugging a system and you |
17
|
|
|
|
|
|
|
wish to easily turn off caching. As a result, all calls return results |
18
|
|
|
|
|
|
|
indicating that there is no data stored. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
package Cache::Null; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
require 5.006; |
24
|
2
|
|
|
2
|
|
1594
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
71
|
|
25
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
47
|
|
26
|
2
|
|
|
2
|
|
669
|
use Cache::Null::Entry; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
52
|
|
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
|
7
|
use base qw(Cache); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
171
|
|
29
|
2
|
|
|
2
|
|
8
|
use fields qw(cache_root); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
8
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our $VERSION = '2.11'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $cache = Cache::Null->new( %options ) |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
The constructor takes cache properties as named arguments, for example: |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $cache = Cache::Null->new( default_expires => '600 sec' ); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
See 'PROPERTIES' below and in the Cache documentation for a list of all |
42
|
|
|
|
|
|
|
available properties that can be set. However it should be noted that all the |
43
|
|
|
|
|
|
|
existing properties, such as default_expires, have no effect in a Null cache. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub new { |
48
|
1
|
|
|
1
|
0
|
320
|
my Cache::Null $self = shift; |
49
|
1
|
50
|
|
|
|
4
|
my $args = $#_? { @_ } : shift; |
50
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
5
|
$self = fields::new($self) unless ref $self; |
52
|
1
|
|
|
|
|
2539
|
$self->SUPER::new($args); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
3
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
See 'Cache' for the API documentation. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub entry { |
64
|
1
|
|
|
1
|
1
|
221
|
my Cache::Null $self = shift; |
65
|
1
|
|
|
|
|
2
|
my ($key) = @_; |
66
|
1
|
|
|
|
|
5
|
return Cache::Null::Entry->new($self, $key); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
0
|
1
|
0
|
sub purge { |
70
|
|
|
|
|
|
|
#my Cache::Null $self = shift; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
1
|
0
|
sub clear { |
74
|
|
|
|
|
|
|
#my Cache::Null $self = shift; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub count { |
78
|
|
|
|
|
|
|
#my Cache::Null $self = shift; |
79
|
0
|
|
|
0
|
1
|
0
|
return 0; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub size { |
83
|
|
|
|
|
|
|
#my Cache::Null $self = shift; |
84
|
2
|
|
|
2
|
1
|
9
|
return 0; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# UTILITY METHODS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub remove_oldest { |
91
|
|
|
|
|
|
|
#my Cache::Null $self = shift; |
92
|
0
|
|
|
0
|
1
|
|
return undef; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub remove_stalest { |
96
|
|
|
|
|
|
|
#my Cache::Null $self = shift; |
97
|
0
|
|
|
0
|
1
|
|
return undef; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
__END__ |