| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CHI::Driver::BerkeleyDB::Manager; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24354
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
37
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
5
|
1
|
|
|
1
|
|
492
|
use BerkeleyDB::Manager; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
|
7
|
|
|
|
|
|
|
use CHI::Constants qw(CHI_Max_Time); |
|
8
|
|
|
|
|
|
|
extends 'CHI::Driver'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my @BERKELEYDB_PARAMS = qw( |
|
11
|
|
|
|
|
|
|
home |
|
12
|
|
|
|
|
|
|
create |
|
13
|
|
|
|
|
|
|
lock |
|
14
|
|
|
|
|
|
|
deadlock_detection |
|
15
|
|
|
|
|
|
|
lk_detect |
|
16
|
|
|
|
|
|
|
readonly |
|
17
|
|
|
|
|
|
|
transactions |
|
18
|
|
|
|
|
|
|
autocommit |
|
19
|
|
|
|
|
|
|
auto_checkpoint |
|
20
|
|
|
|
|
|
|
checkpoint_kbyte |
|
21
|
|
|
|
|
|
|
checkpoint_min |
|
22
|
|
|
|
|
|
|
recover |
|
23
|
|
|
|
|
|
|
multiversion |
|
24
|
|
|
|
|
|
|
snapshot |
|
25
|
|
|
|
|
|
|
read_uncomitted |
|
26
|
|
|
|
|
|
|
log_auto_remove |
|
27
|
|
|
|
|
|
|
sync |
|
28
|
|
|
|
|
|
|
dup |
|
29
|
|
|
|
|
|
|
dupsort |
|
30
|
|
|
|
|
|
|
db_class |
|
31
|
|
|
|
|
|
|
env_flags |
|
32
|
|
|
|
|
|
|
db_properties |
|
33
|
|
|
|
|
|
|
open_dbs |
|
34
|
|
|
|
|
|
|
chunk_size |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has _bdb_manager => ( is => 'rw', lazy => 1, builder => 1 ); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has _bdb_manager_args => ( is => 'rw' ); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#has _bdb => ( is => 'rw', lazy => 1, builder => 1 ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
CHI::Driver::BerkeleyDB::Manager - The great new CHI::Driver::BerkeleyDB::Manager! |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 VERSION |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Version 0.01 |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Quick summary of what the module does. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Perhaps a little code snippet. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
use CHI::Driver::BerkeleyDB::Manager; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $foo = CHI::Driver::BerkeleyDB::Manager->new(); |
|
65
|
|
|
|
|
|
|
... |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 _build__bdb_manager |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
builds the BerkeleyDB::Manager object from the args pass to the driver |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _build__bdb_manager { |
|
77
|
|
|
|
|
|
|
my ($self) = @_; |
|
78
|
|
|
|
|
|
|
return BerkeleyDB::Manager->new(%{$self->_bdb_manager_args}); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 _build__bdb |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
builds the BerkeleyDB::Manager object from the args pass to the driver |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _build__bdb { |
|
87
|
|
|
|
|
|
|
my ($self) = @_; |
|
88
|
|
|
|
|
|
|
return $self->_bdb_manager->open_db( file => $self->namespace ); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
=cut |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _bdb { |
|
93
|
|
|
|
|
|
|
my ($self) = @_; |
|
94
|
|
|
|
|
|
|
return $self->_bdb_manager->open_db( file => $self->namespace ); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 BUILD |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Creates a hash of the BerkeleyDB::Manager arguements |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub BUILD { |
|
104
|
|
|
|
|
|
|
my ($self, $options) = @_; |
|
105
|
|
|
|
|
|
|
my @foundkeys = grep { exists $options->{$_} } @BERKELEYDB_PARAMS; |
|
106
|
|
|
|
|
|
|
my %tmp; |
|
107
|
|
|
|
|
|
|
@tmp{@foundkeys} = delete @{$options}{@foundkeys}; |
|
108
|
|
|
|
|
|
|
$self->_bdb_manager_args(\%tmp); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 store |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub store { |
|
116
|
|
|
|
|
|
|
my ( $self, $key, $data, $expires_in ) = @_; |
|
117
|
|
|
|
|
|
|
die "must specify key" unless defined $key; |
|
118
|
|
|
|
|
|
|
return $self->_bdb_manager->txn_do( sub { $self->_bdb->db_put($key,$data) } ); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 fetch |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub fetch { |
|
126
|
|
|
|
|
|
|
my ( $self, $key ) = @_; |
|
127
|
|
|
|
|
|
|
die "must specify key" unless defined $key; |
|
128
|
|
|
|
|
|
|
my $val; |
|
129
|
|
|
|
|
|
|
$self->_bdb_manager->txn_do( sub { $self->_bdb->db_get($key,$val) } ); |
|
130
|
|
|
|
|
|
|
return $val; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 remove |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub remove { |
|
138
|
|
|
|
|
|
|
my ( $self, $key ) = @_; |
|
139
|
|
|
|
|
|
|
die "must specify key" unless defined $key; |
|
140
|
|
|
|
|
|
|
return $self->_bdb_manager->txn_do( sub { $self->_bdb->db_del($key) } ); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 get_keys |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub get_keys { |
|
149
|
|
|
|
|
|
|
my ( $self ) = @_; |
|
150
|
|
|
|
|
|
|
my $s = $self->_bdb_manager->cursor_stream( db => $self->_bdb, 'keys' => 1); |
|
151
|
|
|
|
|
|
|
my @items = $s->items; |
|
152
|
|
|
|
|
|
|
return @items; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 AUTHOR |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
James Rouzier, C<< <rouzier at gmail.com> >> |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 BUGS |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-chi-driver-berkeleydb_managerdb at rt.cpan.org>, or through |
|
162
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CHI-Driver-BerkeleyDB::Manager>. I will be notified, and then you'll |
|
163
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 SUPPORT |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
perldoc CHI::Driver::BerkeleyDB::Manager |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
You can also look for information at: |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=over 4 |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CHI-Driver-BerkeleyDB::Manager> |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
L<http://annocpan.org/dist/CHI-Driver-BerkeleyDB::Manager> |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/CHI-Driver-BerkeleyDB::Manager> |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item * Search CPAN |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/CHI-Driver-BerkeleyDB::Manager/> |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=back |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Copyright 2014 James Rouzier. |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This program is free software; you can berkeleydb_managertribute it and/or modify it |
|
206
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
207
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
1; # End of CHI::Driver::BerkeleyDB::Manager |