BDB
view release on metacpan or search on metacpan
$int = $env->mutex_set_increment (U32 increment)
$int = $env->mutex_set_tas_spins (U32 tas_spins)
$int = $env->mutex_set_max (U32 max)
$int = $env->mutex_set_align (U32 align)
$txn = $env->txn_begin (DB_TXN_ornull *parent = 0, U32 flags = 0)
flags: READ_COMMITTED READ_UNCOMMITTED TXN_NOSYNC TXN_NOWAIT TXN_SNAPSHOT TXN_SYNC TXN_WAIT TXN_WRITE_NOSYNC
$txn = $env->cdsgroup_begin; (v4.5)
Example:
use AnyEvent;
use BDB;
our $FH; open $FH, "<&=" . BDB::poll_fileno;
our $WATCHER = AnyEvent->io (fh => $FH, poll => 'r', cb => \&BDB::poll_cb);
BDB::min_parallel 8;
my $env = db_env_create;
mkdir "bdtest", 0700;
db_env_open
$env,
"bdtest",
BDB::INIT_LOCK | BDB::INIT_LOG | BDB::INIT_MPOOL | BDB::INIT_TXN | BDB::RECOVER | BDB::USE_ENVIRON | BDB::CREATE,
0600;
$env->set_flags (BDB::AUTO_COMMIT | BDB::TXN_NOSYNC, 1);
DB/database methods
Methods available on DB/$db handles:
DESTROY (DB_ornull *db)
CODE:
if (db)
{
SV *env = (SV *)db->app_private;
db->close (db, 0);
SvREFCNT_dec (env);
}
$int = $db->set_cachesize (U32 gbytes, U32 bytes, int ncache = 0)
$int = $db->set_flags (U32 flags)
flags: CHKSUM ENCRYPT TXN_NOT_DURABLE
Btree: DUP DUPSORT RECNUM REVSPLITOFF
Hash: DUP DUPSORT
Queue: INORDER
Recno: RENUMBER SNAPSHOT
$int = $db->set_encrypt (const char *password, U32 flags)
$int = $db->set_lorder (int lorder)
$int = $db->set_bt_minkey (U32 minkey)
$int = $db->set_re_delim (int delim)
$int = $db->set_re_pad (int re_pad)
$int = $db->set_re_source (char *source)
$int = $db->set_re_len (U32 re_len)
$int = $db->set_h_ffactor (U32 h_ffactor)
$int = $db->set_h_nelem (U32 h_nelem)
$int = $db->set_q_extentsize (U32 extentsize)
$dbc = $db->cursor (DB_TXN_ornull *txn = 0, U32 flags = 0)
flags: READ_COMMITTED READ_UNCOMMITTED WRITECURSOR TXN_SNAPSHOT
$seq = $db->sequence (U32 flags = 0)
Example:
my $db = db_create $env;
db_open $db, undef, "table", undef, BDB::BTREE, BDB::AUTO_COMMIT | BDB::CREATE | BDB::READ_UNCOMMITTED, 0600;
for (1..1000) {
db_put $db, undef, "key $_", "data $_";
db_key_range $db, undef, "key $_", my $keyrange;
my ($lt, $eq, $gt) = @$keyrange;
}
db_del $db, undef, "key $_" for 1..1000;
db_sync $db;
DB_TXN/transaction methods
Methods available on DB_TXN/$txn handles:
DESTROY (DB_TXN_ornull *txn)
CODE:
if (txn)
txn->abort (txn);
$int = $txn->set_timeout (NV timeout_seconds, U32 flags = SET_TXN_TIMEOUT)
flags: SET_LOCK_TIMEOUT SET_TXN_TIMEOUT
$bool = $txn->failed
# see db_txn_finish documentation, above
DBC/cursor methods
Methods available on DBC/$dbc handles:
DESTROY (DBC_ornull *dbc)
CODE:
if (dbc)
dbc->c_close (dbc);
$int = $cursor->set_priority ($priority = PRIORITY_*) (v4.6)
Example:
my $c = $db->cursor;
for (;;) {
db_c_get $c, my $key, my $data, BDB::NEXT;
warn "<$!,$key,$data>";
last if $!;
}
db_c_close $c;
DB_SEQUENCE/sequence methods
Methods available on DB_SEQUENCE/$seq handles:
DESTROY (DB_SEQUENCE_ornull *seq)
CODE:
if (seq)
seq->close (seq, 0);
$int = $seq->initial_value (db_seq_t value)
$int = $seq->set_cachesize (U32 size)
$int = $seq->set_flags (U32 flags)
flags: SEQ_DEC SEQ_INC SEQ_WRAP
$int = $seq->set_range (db_seq_t min, db_seq_t max)
Example:
my $seq = $db->sequence;
db_sequence_open $seq, undef, "seq", BDB::CREATE;
db_sequence_get $seq, undef, 1, my $value;
SUPPORT FUNCTIONS
EVENT PROCESSING AND EVENT LOOP INTEGRATION
$msg = BDB::strerror [$errno]
Returns the string corresponding to the given errno value. If no
argument is given, use $!.
Note that the BDB module also patches the $! variable directly, so
you should be able to get a bdb error string by simply stringifying
$!.
$fileno = BDB::poll_fileno
Return the *request result pipe file descriptor*. This filehandle
must be polled for reading by some mechanism outside this module
(e.g. Event or select, see below or the SYNOPSIS). If the pipe
becomes readable you have to call "poll_cb" to check the results.
See "poll_cb" for an example.
BDB::poll_cb
Process some outstanding events on the result pipe. You have to call
this regularly. Returns the number of events processed. Returns
immediately when no events are outstanding. The amount of events
processed depends on the settings of "BDB::max_poll_req" and
"BDB::max_poll_time".
If not all requests were processed for whatever reason, the
filehandle will still be ready when "poll_cb" returns.
Example: Install an Event watcher that automatically calls
BDB::poll_cb with high priority:
( run in 0.342 second using v1.01-cache-2.11-cpan-39bf76dae61 )