| 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 |
use strict; |
|---|
| 25 |
use warnings; |
|---|
| 26 |
use Cache::Null::Entry; |
|---|
| 27 |
|
|---|
| 28 |
use base qw(Cache); |
|---|
| 29 |
use fields qw(cache_root); |
|---|
| 30 |
|
|---|
| 31 |
our $VERSION = '2.04'; |
|---|
| 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 |
my Cache::Null $self = shift; |
|---|
| 49 |
my $args = $#_? { @_ } : shift; |
|---|
| 50 |
|
|---|
| 51 |
$self = fields::new($self) unless ref $self; |
|---|
| 52 |
$self->SUPER::new($args); |
|---|
| 53 |
|
|---|
| 54 |
return $self; |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
=head1 METHODS |
|---|
| 58 |
|
|---|
| 59 |
See 'Cache' for the API documentation. |
|---|
| 60 |
|
|---|
| 61 |
=cut |
|---|
| 62 |
|
|---|
| 63 |
sub entry { |
|---|
| 64 |
my Cache::Null $self = shift; |
|---|
| 65 |
my ($key) = @_; |
|---|
| 66 |
return Cache::Null::Entry->new($self, $key); |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
sub purge { |
|---|
| 70 |
|
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
sub clear { |
|---|
| 74 |
|
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
sub count { |
|---|
| 78 |
|
|---|
| 79 |
return 0; |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
sub size { |
|---|
| 83 |
|
|---|
| 84 |
return 0; |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
sub remove_oldest { |
|---|
| 91 |
|
|---|
| 92 |
return undef; |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
sub remove_stalest { |
|---|
| 96 |
|
|---|
| 97 |
return undef; |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
1; |
|---|
| 103 |
__END__ |
|---|
| 104 |
|
|---|
| 105 |
=head1 SEE ALSO |
|---|
| 106 |
|
|---|
| 107 |
Cache |
|---|
| 108 |
|
|---|
| 109 |
=head1 AUTHOR |
|---|
| 110 |
|
|---|
| 111 |
Chris Leishman <chris@leishman.org> |
|---|
| 112 |
Based on work by DeWitt Clinton <dewitt@unto.net> |
|---|
| 113 |
|
|---|
| 114 |
=head1 COPYRIGHT |
|---|
| 115 |
|
|---|
| 116 |
Copyright (C) 2003-2006 Chris Leishman. All Rights Reserved. |
|---|
| 117 |
|
|---|
| 118 |
This module is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, |
|---|
| 119 |
either expressed or implied. This program is free software; you can |
|---|
| 120 |
redistribute or modify it under the same terms as Perl itself. |
|---|
| 121 |
|
|---|
| 122 |
$Id: Null.pm,v 1.4 2006/01/31 15:23:58 caleishm Exp $ |
|---|
| 123 |
|
|---|
| 124 |
=cut |
|---|
| 125 |
|
|---|