Berkeley DB environment is an encapsulation of one or more databases, log files and shared information about the database environment such as shared memory buffer cache pages.
The simplest way to administer a Berkeley DB application environment is to create a single home directory that stores the files for the applications that will share the environment. The environment home directory must be created before any Berkeley DB applications are run. Berkeley DB itself never creates the environment home directory. The environment can then be identified by the name of that directory.
open(home, flags = 0, mode = 0, options = {})
create(home, flags = 0, mode = 0, options = {})
new(home, flags = 0, mode = 0, options = {})
Hash, Possible options are (see the documentation of Berkeley DB for more informations)
Proc given to set_feedback, set_app_dispatch and set_rep_transport can be also specified as a method (replace the prefix set_ with bdb_)
For bdb_rep_transport the constant ENVID must be defined
The constant BDB_ENCRYPT can be used to replace set_encrypt
remove()
unlink()
close()
dbremove(file, database = nil, flags = 0)
only with BDB::VERSION_MAJOR == 4 && BDB::VERSION_MINOR >= 1
remove the database specified by file and database. If no database is nil, the underlying file represented by file is removed, incidentally removing all databases that it contained.
The flags value must be set to 0 or BDB::AUTO_COMMIT
dbrename(file, database, newname, flags = 0)
only with BDB::VERSION_MAJOR == 4 && BDB::VERSION_MINOR >= 1
rename the database specified by file and database to newname. If database is nil, the underlying file represented by file is renamed, incidentally renaming all databases that it contained.
The flags value must be set to 0 or BDB::AUTO_COMMIT
feedback=(proc)
home()
lock()
lock_id()
lock_detect(type, flags = 0)
The lock_detect function runs one iteration of the deadlock detector. The deadlock detector traverses the lock table, and for each deadlock it finds, marks one of the participating transactions for abort.
type can have one the value BDB::LOCK_OLDEST, BDB::LOCK_RANDOM or BDB::LOCK_YOUNGUEST
flags can have the value BDB::LOCK_CONFLICT, in this case the deadlock detector is run only if a lock conflict has occurred since the last time that the deadlock detector was run.
return the number of transactions aborted by the lock_detect function if BDB::VERSION_MAJOR >= 3 or zero
lock_stat()
log_archive(flags = 0)
The log_archive function return an array of log or database file names.
flags value must be set to 0 or the value BDB::ARCH_DATA, BDB::ARCH_ABS, BDB::ARCH_LOG
log_checkpoint(string)
log_curlsn(string)
log_each { |string, lsn| ... }
log_flush(string = nil)
same as log_put(string, BDB::FLUSH)
Without argument, garantee that all records are written to the disk
log_get(flag)
The log_get return an array [String, BDB::Lsn] according to the flag value.
flag can has the value BDB::CHECKPOINT, BDB::FIRST, BDB::LAST, BDB::NEXT, BDB::PREV, BDB::CURRENT
log_put(string, flag = 0)
The log_put function appends records to the log. It return an object BDB::Lsn
flag can have the value BDB::CHECKPOINT, BDB::CURLSN, BDB::FLUSH
log_reverse_each { |string, lsn| ... }
log_stat
open_db(type, name = nil, subname = nil, flags = 0, mode = 0)
recover { |txn, id| ... }
only with BDB::VERSION_MAJOR == 3 && BDB::VERSION_MINOR >= 3
iterate over all prepared transactions. The transaction txn must be made a call to #abort, #commit, #discard
id is the global transaction ID for the transaction
set_flags(flags, onoff = true)
only with BDB::VERSION_MAJOR == 3 && BDB::VERSION_MINOR >= 2
flags can have the value BDB::CDB_ALLDB, BDB::NOMMAP BDB::TXN_NOSYNC
if onoff is false, the specified flags are cleared
begin(flags = 0)
txn_begin(flags = 0)
begin(flags = 0, db, ...) { |txn, db, ...| ...}
checkpoint(kbyte, min = 0)
txn_checkpoint(kbyte, min = 0)
The txn_checkpoint function flushes the underlying memory pool, writes a checkpoint record to the log and then flushes the log.
If either kbyte or min is non-zero, the checkpoint is only done if more than min minutes have passed since the last checkpoint, or if more than kbyte kilobytes of log data have been written since the last checkpoint.
stat()
txn_stat()
repmgr_add_remote(host, port, flag = 0)
Only for DB >= 4.5
Adds a new replication site to the replication manager's list of known sites.
Return the environment ID assigned to the remote site
repmgr_ack_policy=(policy)
repmgr_set_ack_policy(policy)
Only for DB >= 4.5
Specifies how master and client sites will handle acknowledgment of replication messages which are necessary for "permanent" records.
policy must be set to one of the following values BDB::REPMGR_ACKS_ALL, BDB::REPMGR_ACKS_ALL_PEERS, BDB::REPMGR_ACKS_NONE, BDB::REPMGR_ACKS_ONE, BDB::REPMGR_ACKS_ONE_PEER, BDB::REPMGR_ACKS_QUORUM
repmgr_ack_policy
repmgr_get_ack_policy
Only for DB >= 4.5
Returns the replication manager's client acknowledgment policy.
repmgr_site_list
Only for DB >= 4.5
Returns an array with the status of the sites currently known by the replication manager.
repmgr_set_local_site(host, port, flag = 0)
Only for DB >= 4.5
Specifies the host identification string and port number for the local system.
repmgr_start(count, flag)
Only for DB >= 4.5
Starts the replication manager.
rep_config[]=(which, onoff)
Only for DB >= 4.5
Configures the Berkeley DB replication subsystem.
which can have the value BDB::REP_CONF_BULK, BDB::REP_CONF_DELAYCLIENT, BDB::REP_CONF_NOAUTOINIT, BDB::REP_CONF_NOWAIT
onoff can have the value true or false
rep_config?[](which)
Only for DB >= 4.5
Returns true if the specified which parameter is currently set or not.
rep_nsites=(sites)
Only for DB >= 4.5
Specifies the total number of sites in a replication group.
rep_nsites
Only for DB >= 4.5
Returns the total number of sites in a replication group.
rep_priority=(priority)
Only for DB >= 4.5
Specifies the priority in the replication group elections.
rep_priority
Only for DB >= 4.5
Returns the database environment priority.
rep_timeout[]=(which, timeout)
Only for DB >= 4.5
Specifies the timeout in the replication group elections.
which can have the value BDB::REP_ACK_TIMEOUT, BDB::REP_ELECTION_TIMEOUT, BDB::REP_ELECTION_RETRY, BDB::REP_CONNECTION_RETRY
rep_timeout[](which)
Only for DB >= 4.5
Returns the database environment timeout for which
elect(sites, priority, timeout)
rep_elect(sites, priority, timeout)
Only for DB >= 4
Holds an election for the master of a replication group, returning the new master's ID
Raise BDB::RepUnavail if the timeout expires
process_message(control, rec, envid)
rep_process_message(control, rec, envid)
Only for DB >= 4
Processes an incoming replication message sent by a member of the replication group to the local database environment
start(cdata, flags)
rep_start(cdata, flags)
Only for DB >= 4
cdata is an identifier flags must be one of BDB::REP_CLIENT, BDB::REP_MASTER or BDB::REP_LOGSONLY
lsn_reset(file, flags = 0)
Only for DB >= 4.4
Reset database file LSN
The Env#lsn_reset method allows database files to be moved from one transactional database environment to another.
fileThe name of the physical file in which the LSNs are to be cleared. flags must be set to 0 or BDB::ENCRYPT
fileid_reset(file, flags = 0)
Only for DB >= 4.4
Reset database file ID
The Env#fileid_reset method allows database files to be copied, and then the copy used in the same database environment as the original.
fileThe name of the physical file in which new file IDs are to be created. flags must be set to 0 or BDB::ENCRYPT
msgcall=(call_proc)
Only for DB >= 4.4
There are interfaces in the Berkeley DB library which either directly output informational messages or statistical information : Env#msgcall is used to set callback which will called by BDB
The value given must be nil to unconfigure the callback, or and object which respond to #call : it will called with a String as argument
thread_id=(call_proc)
Only for DB >= 4.4
Declare a proc object which returns a unique identifier pair for the current thread of control.
The proc must return a pair
thread_id_string=(call_proc)
Only for DB >= 4.4
Declare a proc that formats a process ID and thread ID identifier pair for display.
The proc will be called with 2 arguments and must return a String
is_alive=(call_proc)
Only for DB >= 4.4
Declare a proc that returns if a thread of control (either a true thread or a process) is still running.
The proc will be called with 2 arguments (pid, tid)
failcheck(flag = 0)
Only for DB >= 4.4
The method checks for threads of control (either a true thread or a process) that have exited while manipulating Berkeley DB library data structures
flag is actually unused and must be set to 0