CHI-Driver-BerkeleyDB-Manager
view release on metacpan or search on metacpan
lib/CHI/Driver/BerkeleyDB/Manager.pm view on Meta::CPAN
=cut
sub _bdb {
my ($self) = @_;
return $self->_bdb_manager->open_db( file => $self->namespace );
}
=head2 BUILD
Creates a hash of the BerkeleyDB::Manager arguements
=cut
sub BUILD {
my ($self, $options) = @_;
my @foundkeys = grep { exists $options->{$_} } @BERKELEYDB_PARAMS;
my %tmp;
@tmp{@foundkeys} = delete @{$options}{@foundkeys};
$self->_bdb_manager_args(\%tmp);
}
=head2 store
=cut
sub store {
my ( $self, $key, $data, $expires_in ) = @_;
die "must specify key" unless defined $key;
return $self->_bdb_manager->txn_do( sub { $self->_bdb->db_put($key,$data) } );
}
=head2 fetch
=cut
sub fetch {
my ( $self, $key ) = @_;
die "must specify key" unless defined $key;
my $val;
$self->_bdb_manager->txn_do( sub { $self->_bdb->db_get($key,$val) } );
return $val;
}
=head2 remove
=cut
sub remove {
my ( $self, $key ) = @_;
die "must specify key" unless defined $key;
return $self->_bdb_manager->txn_do( sub { $self->_bdb->db_del($key) } );
}
=head2 get_keys
=cut
sub get_keys {
my ( $self ) = @_;
my $s = $self->_bdb_manager->cursor_stream( db => $self->_bdb, 'keys' => 1);
my @items = $s->items;
return @items;
}
=head1 AUTHOR
James Rouzier, C<< <rouzier at gmail.com> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-chi-driver-berkeleydb_managerdb at rt.cpan.org>, or through
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
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc CHI::Driver::BerkeleyDB::Manager
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CHI-Driver-BerkeleyDB::Manager>
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/CHI-Driver-BerkeleyDB::Manager>
=item * CPAN Ratings
L<http://cpanratings.perl.org/d/CHI-Driver-BerkeleyDB::Manager>
=item * Search CPAN
L<http://search.cpan.org/dist/CHI-Driver-BerkeleyDB::Manager/>
=back
=head1 ACKNOWLEDGEMENTS
=head1 LICENSE AND COPYRIGHT
Copyright 2014 James Rouzier.
This program is free software; you can berkeleydb_managertribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
( run in 1.641 second using v1.01-cache-2.11-cpan-140bd7fdf52 )