| 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 | 2 | require 5.006; | |||||||||
| 24 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 2 | ▶ | use Cache::Null::Entry; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 2 | ▶ | use base qw(Cache); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 2 | ▶ | use fields qw(cache_root); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 2 | 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 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||
| 48 | 1 | my Cache::Null $self = shift; | |||||||||
| 49 | 1 | ▶ | my $args = $#_? { @_ } : shift; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | 1 | ▶ | $self = fields::new($self) unless ref $self; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 1 | $self->SUPER::new($args); | |||||||||
| 53 | |||||||||||
| 54 | 1 | return $self; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | =head1 METHODS | ||||||||||
| 58 | |||||||||||
| 59 | See 'Cache' for the API documentation. | ||||||||||
| 60 | |||||||||||
| 61 | =cut | ||||||||||
| 62 | |||||||||||
| 63 | 1 | ▶ | sub entry { | ||||||||
|
Subroutine
entry: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 64 | 1 | my Cache::Null $self = shift; | |||||||||
| 65 | 1 | my ($key) = @_; | |||||||||
| 66 | 1 | return Cache::Null::Entry->new($self, $key); | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | sub purge { | ||||||||
|
Subroutine
purge: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 70 | #my Cache::Null $self = shift; | ||||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | sub clear { | ||||||||
|
Subroutine
clear: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 74 | #my Cache::Null $self = shift; | ||||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | sub count { | ||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 78 | #my Cache::Null $self = shift; | ||||||||||
| 79 | 0 | return 0; | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 2 | ▶ | sub size { | ||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 83 | #my Cache::Null $self = shift; | ||||||||||
| 84 | 2 | return 0; | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | |||||||||||
| 88 | # UTILITY METHODS | ||||||||||
| 89 | |||||||||||
| 90 | 0 | ▶ | sub remove_oldest { | ||||||||
|
Subroutine
remove_oldest: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 91 | #my Cache::Null $self = shift; | ||||||||||
| 92 | 0 | return undef; | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | 0 | ▶ | sub remove_stalest { | ||||||||
|
Subroutine
remove_stalest: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 96 | #my Cache::Null $self = shift; | ||||||||||
| 97 | 0 | return undef; | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | |||||||||||
| 101 | |||||||||||
| 102 | 2 | 1; | |||||||||
| 103 | __END__ | ||||||||||