File Coverage

blib/lib/Cache/Repository.pm
Criterion Covered Total %
statement 76 150 50.6
branch 26 60 43.3
condition 5 11 45.4
subroutine 9 20 45.0
pod 13 13 100.0
total 129 254 50.7


line stmt bran cond sub pod time code
1             package Cache::Repository;
2              
3             our $VERSION = '0.07';
4              
5 1     1   912 use strict;
  1         2  
  1         24  
6 1     1   6 use warnings;
  1         2  
  1         32  
7 1     1   796 use IO::File;
  1         11413  
  1         171  
8 1     1   7 use Carp;
  1         2  
  1         1805  
9              
10             =head1 NAME
11              
12             Cache::Repository - Generic repository of files
13              
14             =head1 SYNOPSIS
15              
16             my $rep = Cache::Repository->new(
17             style => 'Filesys',
18             # options for the F::R driver
19             );
20             $rep->add_files(tag => 'groupname',
21             files => \@filenames,
22             basedir => '/tmp',
23             move => 1,
24             );
25             $rep->add_filehandle(tag => 'anothergroup',
26             filename => 'blah',
27             filehandle => $fh,
28             mode => 0755);
29             $rep->set_meta(tag => 'groupname',
30             meta => {
31             title => 'blah',
32             author => 'foo',
33             });
34              
35             $rep->retrieve(tag => 'groupname', dest => '/newdir');
36             my $data = $rep->get_meta(tag => 'groupname');
37              
38             =head1 DESCRIPTION
39              
40             This module is intended to serve as a repository for files, whether those
41             files are local or remote. Different drivers can work independantly to
42             provide differing backing stores. For example, one driver can use a
43             locally-mounted filesystem (even if that is a network filesystem), another
44             could use FTP or HTTP, another could use gmail, and another could use a
45             relational database such as MySQL or DB2.
46              
47             Drivers may choose to compress the repository, unless explicitly told
48             otherwise.
49              
50             Keeping this in mind, the API presented here cannot expose things that are
51             not generic to other possible implementations. That said, some possible
52             implementations may not allow adding ("sending" to a web server) - it is
53             expected that they will either throw an exception, or take extra params for
54             FTP'ing to the server.
55              
56             =head1 FUNCTIONS
57              
58             =over 4
59              
60             =item new
61              
62             Cache::Repository constructor. The constructor will load the driver and
63             return an object of the driver package. All other parameters will be passed
64             to the driver for initialisation.
65              
66             my $r = Cache::Repository->new(
67             style => 'Filesys',
68             # ...
69             );
70              
71             It is up to the underlying driver to determine if the repository created
72             by this is persistant for other processes (e.g., meta-data or even data stored
73             in RAM wouldn't be persistant), or to handle locking issues should multiple
74             processes be accessing the repository simultaneously.
75              
76             Parameters:
77              
78             =over 4
79              
80             =item style
81              
82             This is the name of the driver. The driver is expected to be
83             Cache::Compress::I