File Coverage

lib/Cache/AgainstFile/Null.pm
Criterion Covered Total %
statement 17 20 85.0
branch n/a
condition n/a
subroutine 8 11 72.7
pod 0 9 0.0
total 25 40 62.5


line stmt bran cond sub pod time code
1             ###############################################################################
2             # Purpose : No caching backend for Cache::AgainstFile
3             # Author : John Alden
4             # Created : 22 Apr 2005 (based on IFL::FileCache)
5             # CVS : $Id: Null.pm,v 1.5 2005/05/26 15:52:19 simonf Exp $
6             ###############################################################################
7              
8             package Cache::AgainstFile::Null;
9              
10 1     1   6 use strict;
  1         2  
  1         42  
11 1     1   6 use vars qw($VERSION);
  1         2  
  1         378  
12             $VERSION = sprintf"%d.%03d", q$Revision: 1.5 $ =~ /: (\d+)\.(\d+)/;
13              
14             sub new {
15 1     1 0 4 my ($class, $loader, $options) = @_;
16 1         4 my $self = {
17             'loader' => $loader,
18             'options' => $options,
19             };
20 1         5 return bless $self, $class;
21             }
22              
23             sub get {
24 1     1 0 3 my $self = shift;
25 1         4 TRACE("Get called on null cache - calling loader");
26 1         8 my $data = $self->{loader}->(@_);
27 1         22 return $data;
28             }
29              
30 1     1 0 3 sub purge {}
31 1     1 0 3 sub clear {}
32 1     1 0 4 sub count {return 0}
33 1     1 0 4 sub size {return 0}
34              
35             # Documented in Cache::AgainstFile::Base
36 0     0 0   sub remove {}
37 0     0 0   sub accessed { +{} }
38 0     0 0   sub stale { () }
39              
40             #Log::Trace stubs
41             sub TRACE {}
42             sub DUMP {}
43              
44             1;
45              
46             =head1 NAME
47              
48             Cache::AgainstFile::Null - backend for Cache::AgainstFile to disable caching
49              
50             =head1 SYNOPSIS
51              
52             my $cache = new Cache::AgainstFile(
53             \&loader,
54             {
55             Method => 'Null',
56             ...
57             }
58             );
59              
60             $data = $cache->get($filename);
61              
62             =head1 DESCRIPTION
63              
64             This implementation simply calls the cache loader each time get() is called, thus no caching is done.
65             It is useful for testing when you want to quickly disable caching by flipping the Method passed to Cache::AgainstFile.
66              
67             =head1 OPTIONS
68              
69             There are no additional options for this backend
70              
71             =head1 VERSION
72              
73             $Revision: 1.5 $ on $Date: 2005/05/26 15:52:19 $ by $Author: simonf $
74              
75             =head1 AUTHOR
76              
77             John Alden
78              
79             =head1 COPYRIGHT
80              
81             (c) BBC 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL.
82              
83             See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt
84              
85             =cut