| 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
|
|
2628
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
92
|
|
|
25
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
64
|
|
|
26
|
2
|
|
|
2
|
|
1541
|
use Cache::Null::Entry; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
59
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
|
11
|
use base qw(Cache); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
225
|
|
|
29
|
2
|
|
|
2
|
|
9
|
use fields qw(cache_root); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
12
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our $VERSION = '2.10'; |
|
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
|
1087
|
my Cache::Null $self = shift; |
|
49
|
1
|
50
|
|
|
|
8
|
my $args = $#_? { @_ } : shift; |
|
50
|
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
10
|
$self = fields::new($self) unless ref $self; |
|
52
|
1
|
|
|
|
|
5605
|
$self->SUPER::new($args); |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
4
|
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
|
745
|
my Cache::Null $self = shift; |
|
65
|
1
|
|
|
|
|
2
|
my ($key) = @_; |
|
66
|
1
|
|
|
|
|
10
|
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
|
12
|
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__ |