Class | BDB::Common |
In: |
common.rb
|
Parent: | Object |
Implement common methods for access to data
The flags value must be set to 0 or by bitwise inclusively OR‘ing together one or more of the following values
The DB_TRUNCATE flag cannot be transaction protected, and it is an error to specify it in a transaction protected environment.
set_append_recno will be called with (key, value) and it must return nil or the modified value
set_encrypt take an Array as arguments with the values [password, flags], where flags can be 0 or BDB::ENCRYPT_AES
Proc given to set_bt_compare, set_bt_prefix, set_dup_compare, set_h_hash, set_store_key set_fetch_key, set_store_value, set_fetch_value set_feedback and set_append_recno can be also specified as a method (replace the prefix set_ with bdb_)
For example module BDB class Btreesort < Btree def bdb_bt_compare(a, b) b.downcase <=> a.downcase end end end
Stores the value associating with key
If nil is given as the value, the association from the key will be removed.
set the priority value : can be BDB::PRIORITY_VERY_LOW, BDB::PRIORITY_LOW, BDB::PRIORITY_DEFAULT, BDB::PRIORITY_HIGH or BDB::PRIORITY_VERY_HIGH
Only for Btree and Recno (DB VERSION >= 4.4)
create a new sequence (see also open_sequence)
equivalent to open_sequence(key, BDB::CREATE|BDB::EXCL, init, options)
return (or yield) an object BDB::Sequence
Removes the association from the key.
It return the object deleted or nil if the specified key don‘t exist.
Return an array of all duplicate associations for key
if assoc is false return only the values.
Iterates over secondary indexes and give secondary key, primary key and value
Returns the value correspondind the key
flags can have the values BDB::GET_BOTH, BDB::SET_RECNO or BDB::RMW
In presence of duplicates it will return the first data item, use
duplicates if you want all duplicates (see also #each_dup)
create or open a sequence (see BDB::Sequence)
key : key for the sequence
flags : flags can have BDB::CREATE, BDB::EXCL, BDB::AUTO_COMMIT, BDB::THREAD
init : initial value for the sequence
options : hash with the possible keys "set_cachesize", "set_flags" and "set_range"
return (or yield) an object BDB::Sequence
Returns the primary key and the value corresponding to key in the secondary index
only with >= 3.3.11
Stores the value associating with key
If nil is given as the value, the association from the key will be removed. It return the object deleted or nil if the specified key don‘t exist.
flags can have the value DBD::NOOVERWRITE, in this case it will return nil if the specified key exist, otherwise true
Iterates over secondary indexes in reverse order and give secondary key, primary key and value