| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Catmandu::Store::CHI - a CHI backed caching store |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# From the command line |
|
8
|
|
|
|
|
|
|
$ catmandu export CHI --driver File --root_dir /data to YAML |
|
9
|
|
|
|
|
|
|
$ catmandu import JSON to CHI --driver File --root_dir /data < data.json |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# From perl |
|
12
|
|
|
|
|
|
|
use Catmandu; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $store = Catmandu->store('CHI', driver => 'File' , root_dir => '/data'); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$store->bag->each(sub { |
|
17
|
|
|
|
|
|
|
my $item = shift; |
|
18
|
|
|
|
|
|
|
... |
|
19
|
|
|
|
|
|
|
}); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$store->bag->add({ test => 123 }); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 METHODS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 new() |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 new(driver => $chi_driver, [OPT => VAL, OPT2 => VAL]) |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Create a new Catmandu::Store::CHI with a $chi_driver and optional parameters. When no driver is given |
|
30
|
|
|
|
|
|
|
then by default the 'Memory' driver will be used. See L<CHI> for more documentation on possible drivers. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 INHERITED METHODS |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This Catmandu::Store implements: |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=over 3 |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item L<Catmandu::Store> |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=back |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Each Catmandu::Bag in this Catmandu::Store implements: |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over 3 |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item L<Catmandu::Bag> |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=back |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
L<CHI> |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 AUTHOR |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Patrick Hochstenbach, C<< <patrick.hochstenbach at ugent.be> >> |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
61
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
62
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
|
67
|
|
|
|
|
|
|
package Catmandu::Store::CHI; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
{ |
|
70
|
|
|
|
|
|
|
$Catmandu::Store::CHI::VERSION = '0.04'; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
2
|
|
|
2
|
|
123196
|
use Moo; |
|
|
2
|
|
|
|
|
19003
|
|
|
|
2
|
|
|
|
|
10
|
|
|
74
|
2
|
|
|
2
|
|
3377
|
use CHI; |
|
|
2
|
|
|
|
|
140011
|
|
|
|
2
|
|
|
|
|
62
|
|
|
75
|
2
|
|
|
2
|
|
821
|
use Catmandu::Store::CHI::Bag; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
263
|
|
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
with 'Catmandu::Store'; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has 'driver' => (is => 'ro' , required => 1 , default => sub { 'Memory' }); |
|
80
|
|
|
|
|
|
|
has 'opts' => (is => 'rw'); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub BUILD { |
|
83
|
1
|
|
|
1
|
0
|
7
|
my ($self,$opts) = @_; |
|
84
|
|
|
|
|
|
|
|
|
85
|
1
|
50
|
|
|
|
5
|
if (keys %$opts == 0) { |
|
86
|
1
|
|
|
|
|
3
|
$opts->{global} = 1; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
16
|
delete $opts->{driver}; |
|
90
|
|
|
|
|
|
|
|
|
91
|
1
|
|
|
|
|
7
|
$self->opts($opts); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |