BerkeleyDB

 view release on metacpan or  search on metacpan

BerkeleyDB.pod.P  view on Meta::CPAN

database and B<DB_RECNO> for a B<BerkeleyDB::Recno> database. This method
is typically used when a database has been opened with
B<BerkeleyDB::Unknown>.

=head2   $bool = $env->cds_enabled();

Returns true if the Berkeley DB environment C<$env> has been opened on
CDS mode.

=head2   $bool = $db->cds_enabled();

Returns true if the database C<$db> has been opened on CDS mode.

=head2 $lock = $db->cds_lock();

Creates a CDS write lock object C<$lock>.

It is a fatal error to attempt to create a cds_lock if the Berkeley DB
environment has not been opened in CDS mode.

=head2 $lock->cds_unlock();

Removes a CDS lock. The destruction of the CDS lock object automatically
calls this method.

Note that if multiple CDS lock objects are created, the underlying write
lock will not be released until all CDS lock objects are either explicitly
unlocked with this method, or the CDS lock objects have been destroyed.

=head2 $ref = $db->db_stat()

Returns a reference to an associative array containing information about
the database. The keys of the associative array correspond directly to the
names of the fields defined in the Berkeley DB documentation. For example,
in the DB documentation, the field B<bt_version> stores the version of the
Btree database. Assuming you called B<db_stat> on a Btree database the
equivalent field would be accessed as follows:

    $version = $ref->{'bt_version'} ;

If you are using Berkeley DB 3.x or better, this method will work will
all database formats. When DB 2.x is used, it only works with
B<BerkeleyDB::Btree>.

=head2 $status = $db->status()

Returns the status of the last C<$db> method called.

=head2 $status = $db->truncate($count)

Truncates the database and returns the number or records deleted
in C<$count>.

=head2  $status = $db->compact($start, $stop, $c_data, $flags, $end);

Compacts the database C<$db>.

All the parameters are optional - if only want to make use of some of them,
use C<undef> for those you don't want.  Trailing unused parameters can be
omitted. For example, if you only want to use the C<$c_data> parameter to
set the C<compact_fillpercent>, write you code like this

    my %hash;
    $hash{compact_fillpercent} = 50;
    $db->compact(undef, undef, \%hash);

The parameters operate identically to the C equivalent of this method.
The C<$c_data> needs a bit of explanation - it must be a hash reference.
The values of the following keys can be set before calling C<compact> and
will affect the operation of the compaction.

=over 5

=item * compact_fillpercent

=item * compact_timeout

=back

The following keys, along with associated values, will be created in the
hash reference if the C<compact> operation was successful.

=over 5

=item * compact_deadlock

=item * compact_levels

=item * compact_pages_free

=item * compact_pages_examine

=item * compact_pages_truncated

=back

You need to be running Berkeley DB 4.4 or better if you want to make use of
C<compact>.

=head2  $status = $db->associate($secondary, \&key_callback)

Associate C<$db> with the secondary DB C<$secondary>

New key/value pairs inserted to the database will be passed to the callback
which must set its third argument to the secondary key to allow lookup. If
an array reference is set multiple keys secondary keys will be associated
with the primary database entry.

Data may be retrieved fro the secondary database using C<db_pget> to also
obtain the primary key.

Secondary databased are maintained automatically.

=head2  $status = $db->associate_foreign($secondary, callback, $flags)

Associate a foreign key database C<$db> with the secondary DB
C<$secondary>.

The second parameter must be a reference to a sub or C<undef>.

The C<$flags> parameter must be either C<DB_FOREIGN_CASCADE>,
C<DB_FOREIGN_ABORT> or C<DB_FOREIGN_NULLIFY>.

When the flags parameter is C<DB_FOREIGN_NULLIFY> the second parameter is a
reference to a sub of the form

    sub foreign_cb
    {
        my $key = \$_[0];
        my $value = \$_[1];
        my $foreignkey = \$_[2];
        my $changed = \$_[3] ;

        # for ... set $$value and set $$changed to 1



( run in 1.203 second using v1.01-cache-2.11-cpan-39bf76dae61 )