These are the common methods for BDB::Btree, BDB::Hash, BDB::Recno and BDB::Queue
open(name = nil, subname = nil, flags = 0, mode = 0, options = {})
create(name = nil, subname = nil, flags = 0, mode = 0, options = {})
new(name = nil, subname = nil, flags = 0, mode = 0, options = {})
The flags must be the string "r", "r+", "w", "w+", "a", "a+" or and integer value.
The flags value must be set to 0 or by bitwise inclusively OR'ing together one or more of the following values
Physically truncate the underlying database file, discarding all previous subdatabases or databases. Underlying filesystem primitives are used to implement this flag. For this reason it is only applicable to the physical database file and cannot be used to discard subdatabases.
The DB_TRUNCATE flag cannot be transaction protected, and it is an error to specify it in a transaction protected environment.
Hash, Possible options are (see the documentation of Berkeley DB for more informations)
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
remove(name, subname = nil)
db_remove(name, subname = nil)
unlink(name, subname = nil)
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.
upgrade(name)
db_upgrade(name)
self[key]
associate(db, flag = 0) { |db, key, value| }
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
cache_priority
cache_priority=value
feedback=(proc)
get(key, flags = 0)
db_get(key, flags = 0)
fetch(key, flags = 0)
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)
pget(key, flags = 0)
Returns the primary key and the value corresponding to key in the secondary index
only with >= 3.3.11
self[key] = value
Stores the value associating with key
If nil is given as the value, the association from the key will be removed.
put(key, value, flags = 0)
db_put(key, value, flags = 0)
store(key, value, flags = 0)
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
append(key, value)
db_append(key, value)
byteswapped?
get_byteswapped
clear_partial
partial_clear
close(flags = 0)
db_close(flags = 0)
count(key)
dup_count(key)
cursor(flags = 0)
db_cursor(flags = 0)
database()
subname()
delete(key)
db_del(key)
Removes the association from the key.
It return the object deleted or nil if the specified key don't exist.
delete_if(set = nil) { |key, value| ... }
reject!(set = nil) { |key, value| ... }
Deletes associations if the evaluation of the block returns true.
duplicates(key , assoc = true)
Return an array of all duplicate associations for key
if assoc is false return only the values.
each(set = nil, bulk = 0, "flags" => 0) { |key, value| ... }
each_pair(set = nil, bulk = 0) { |key, value| ... }
Iterates over associations.
each_by_prefix(prefix) {|key, value| ... }
each_dup(key, bulk = 0) { |key, value| ... }
Iterates over each duplicate associations for key
each_dup_value(key, bulk = 0) { |value| ... }
Iterates over each duplicate values for key
each_key(set = nil, bulk = 0) { |key| ... }
Iterates over keys.
each_primary(set = nil) { |skey, pkey, pvalue| ... }
each_value(set = nil, bulk = 0) { |value| ... }
Iterates over values.
empty?()
filename()
has_key?(key)
key?(key)
include?(key)
member?(key)
has_both?(key, value)
both?(key, value)
has_value?(value)
value?(value)
index(value)
indexes(value1, value2, )
join(cursor , flag = 0) { |key, value| ... }
keys
length
size
log_register(name)
log_unregister()
reject { |key, value| ... }
reverse_each(set = nil) { |key, value| ... }
reverse_each_pair(set = nil) { |key, value| ... }
Iterates over associations in reverse order
reverse_each_by_prefix(prefix) {|key, value| ... }
reverse_each_key(set = nil) { |key| ... }
Iterates over keys in reverse order
reverse_each_primary(set = nil) { |skey, pkey, pvalue| ... }
reverse_each_value(set = nil) { |value| ... }
Iterates over values in reverse order.
set_partial(len, offset)
stat
to_a
to_hash
truncate
clear
values
verify(file = nil, flags = 0)
compact(start = nil, stop = nil, options = nil)
pop
push values
shift
If the parameter set is given, an initial call will be made with the option BDB::SET_RANGE to move the cursor to the specified key before iterating.
Only with >= 3.3.11 : if the parameter bulk is given, an application buffer of size bulk * 1024 will be used (see "Retrieving records in bulk" in the documentation of BerkeleyDB)