NAME

Paranoid::BerkeleyDB::Db -- BerkeleyDB Db Wrapper

VERSION

$Id: lib/Paranoid/BerkeleyDB/Db.pm, 2.06 2022/03/08 22:26:06 acorliss Exp $

SYNOPSIS

$db = Paranoid::BerkeleyDB::Db->new(
  -Env       => $env,
  -Filename => './dbdir/data.db',
  );

$fn     = $db->filename;
%params = $db->params;
$count  = $db->refc;
$bdb    = $db->dbh;

DESCRIPTION

This module provides an OO-based wrapper for the BerkeleyDB::Btree(3) class with the standard Paranoid(3) API integration. This module can be sued with or without a CDS environment and supports all of the standard parameters that BerkeleyDB::Btree(3) does.

If you're using the Paranoid::BerkeleyDB(3) API this object is created for you automatically. There is probably no value in using this module directly unless you need to tune BerkeleyDB::Btree's defaults.

Note that you can't have the same db open at the same time with different options. Which ever options were used for the first call is what's in effect since subsequent calls to open the database will simply return cached references.

SUBROUTINES/METHODS

new

$db = Paranoid::BerkeleyDB::Db->new(
  -Env       => $env,
  -Filename => './dbdir/data.db',
  );

The only required argument is -Filename. For a complete list of all available options please see the BerkeleyDB(3) man page.

By default the following settings are applied unless overridden:

Parameter   Value
---------------------------------------------------
-Flags      DB_CREATE
-Mode       0666 &~ umask

If you decided to pass a custom BerkeleyDB environment it needs to be done via Paranoid::BerkeleyDB::Env or it will be ignored.

filename

$fn = $db->filename;

This method returns the canonical path to the specified db file.

params

%params = $db->params;

This method returns the assembled parameters hash used to open the BerkeleyDB object, minus the environment reference (if passed).

refc

$count = $db->refc;

This method returns the current number of references to the underlying database object. That count is essentially the number of objects all using the same database.

dbh

$db = $db->dbh;

This returns a handle to the current BerkeleyDB::Btree(3) object.

DESTROY

A DESTROY method is provided which should sync and close an open database, as well as release any locks.

DEPENDENCIES

o

BerkeleyDB

o

Carp

o

Cwd

o

Class::EHierarchy

o

Paranoid

o

Paranoid::Debug

o

Paranoid::Filesystem

o

Paranoid::Input

o

Paranoid::IO

o

Paranoid::IO::Lockfile

BUGS AND LIMITATIONS

BerkeleyDB(3) does not support forking, and neither does this module. This module will croak if any methods are called on objects created under a different PID. Because of the nature of BerkeleyDB's file handle usage this will likely wreak some havoc in the parent process, so note that it is imperative that you're checking child exit values.

SEE ALSO

L<BerkeleyDB(3)>

HISTORY

02/12/2016 Complete rewrite 03/21/2017 Ported to new Class::EHierarchy API

AUTHOR

Arthur Corliss (corliss@digitalmages.com)

LICENSE AND COPYRIGHT

This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information.

(c) 2005 - 2022, Arthur Corliss (corliss@digitalmages.com)