In: |
bdb.rb
|
Parent: | Object |
Implement common methods for access to data
open the database
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
Removes the database (or subdatabase) represented by the name and subname combination.
If no subdatabase is specified, the physical file represented by name is removed, incidentally removing all subdatabases that it contained.
associate a secondary index db
flag can have the value BDB::RDONLY
The block must return the new key, or Qfalse in this case the secondary index will not contain any reference to key/value
set the priority value : can be BDB::PRIORITY_VERY_LOW, BDB::PRIORITY_LOW, BDB::PRIORITY_DEFAULT, BDB::PRIORITY_HIGH or BDB::PRIORITY_VERY_HIGH
Removes the association from the key.
It return the object deleted or nil if the specified key don’t exist.
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)
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
Stores the value associating with key
If nil is given as the value, the association from the key will be removed.