… | |
… | |
25 | db_sync $db; |
25 | db_sync $db; |
26 | |
26 | |
27 | # when you also use Coro, management is easy: |
27 | # when you also use Coro, management is easy: |
28 | use Coro::BDB; |
28 | use Coro::BDB; |
29 | |
29 | |
30 | # automatic event loop intergration with AnyEvent: |
30 | # automatic event loop integration with AnyEvent: |
31 | use AnyEvent::BDB; |
31 | use AnyEvent::BDB; |
32 | |
32 | |
33 | # automatic result processing with EV: |
33 | # automatic result processing with EV: |
34 | my $WATCHER = EV::io BDB::poll_fileno, EV::READ, \&BDB::poll_cb; |
34 | my $WATCHER = EV::io BDB::poll_fileno, EV::READ, \&BDB::poll_cb; |
35 | |
35 | |
… | |
… | |
152 | db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = 0) |
152 | db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = 0) |
153 | db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = 0) |
153 | db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = 0) |
154 | db_env_dbremove (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, U32 flags = 0, SV *callback = 0) |
154 | db_env_dbremove (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, U32 flags = 0, SV *callback = 0) |
155 | db_env_dbrename (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, bdb_filename newname, U32 flags = 0, SV *callback = 0) |
155 | db_env_dbrename (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, bdb_filename newname, U32 flags = 0, SV *callback = 0) |
156 | db_env_log_archive (DB_ENV *env, SV *listp, U32 flags = 0, SV *callback = 0) |
156 | db_env_log_archive (DB_ENV *env, SV *listp, U32 flags = 0, SV *callback = 0) |
|
|
157 | db_env_lsn_reset (DB_ENV *env, bdb_filename db, U32 flags = 0, SV *callback = 0) |
|
|
158 | db_env_fileid_reset (DB_ENV *env, bdb_filename db, U32 flags = 0, SV *callback = 0) |
157 | |
159 | |
158 | $db = db_create (DB_ENV *env = 0, U32 flags = 0) |
160 | $db = db_create (DB_ENV *env = 0, U32 flags = 0) |
159 | flags: XA_CREATE |
161 | flags: XA_CREATE |
160 | |
162 | |
161 | db_open (DB *db, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, int type, U32 flags, int mode, SV *callback = 0) |
163 | db_open (DB *db, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, int type, U32 flags, int mode, SV *callback = 0) |
… | |
… | |
390 | flags: SEQ_DEC SEQ_INC SEQ_WRAP |
392 | flags: SEQ_DEC SEQ_INC SEQ_WRAP |
391 | $int = $seq->set_range (db_seq_t min, db_seq_t max) |
393 | $int = $seq->set_range (db_seq_t min, db_seq_t max) |
392 | |
394 | |
393 | Example: |
395 | Example: |
394 | my $seq = $db->sequence; |
396 | my $seq = $db->sequence; |
395 | |
397 | |
396 | db_sequence_open $seq, undef, "seq", BDB::CREATE; |
398 | db_sequence_open $seq, undef, "seq", BDB::CREATE; |
397 | db_sequence_get $seq, undef, 1, my $value; |
399 | db_sequence_get $seq, undef, 1, my $value; |
398 | |
400 | |
399 | SUPPORT FUNCTIONS |
401 | SUPPORT FUNCTIONS |
400 | EVENT PROCESSING AND EVENT LOOP INTEGRATION |
402 | EVENT PROCESSING AND EVENT LOOP INTEGRATION |
401 | $msg = BDB::strerror [$errno] |
403 | $msg = BDB::strerror [$errno] |
… | |
… | |
644 | |
646 | |
645 | COMMON PITFALLS |
647 | COMMON PITFALLS |
646 | Unexpected Crashes |
648 | Unexpected Crashes |
647 | Remember that, by default, BDB will execute requests in parallel, in |
649 | Remember that, by default, BDB will execute requests in parallel, in |
648 | somewhat random order. That means that it is easy to run a "db_get" |
650 | somewhat random order. That means that it is easy to run a "db_get" |
649 | request on thesa me database as a concurrent "db_close" request, leading |
651 | request on the same database as a concurrent "db_close" request, leading |
650 | to a crash, silent data corruption, eventually the next world war on |
652 | to a crash, silent data corruption, eventually the next world war on |
651 | terrorism. |
653 | terrorism. |
652 | |
654 | |
653 | If you only ever use foreground requests (without a callback), this will |
655 | If you only ever use foreground requests (without a callback), this will |
654 | not be an issue. |
656 | not be an issue (unless you use threads). |
655 | |
657 | |
656 | Unexpected Freezes or Deadlocks |
658 | Unexpected Freezes or Deadlocks |
657 | Remember that, by default, BDB will execute requests in parallel, which |
659 | Remember that, by default, BDB will execute requests in parallel, which |
658 | easily leads to deadlocks (even concurrent put's on the same database |
660 | easily leads to deadlocks (even concurrent put's on the same database |
659 | can deadlock). |
661 | can deadlock). |