stdlib : gdbm
close
db.close
Close the database
closed?
db.closed?
Check if the database is closed.
delete
db.delete key
Delete key from the database.
each
db.each { key, value block }
Iterate over each key-value pair in the database.
each_key
db.each_key { key block }
Iterate over the keys in the database.
each_value
db.each_value { value block }
Iterate over the values in the database.
get
db.get key
db[key]
Fetch a string value based on it’s string key.
key?
db.key? key
Check if the given string is a key in the database.
keys
db.keys
Return an array of the keys in the database.
open
gdbm.open path
gdbm.open path, mode
gdbm.open path, { db | block }
gdbm.open path, mode, { db | block }
Open database at the given path.
The mode can be one of the following:
- “r” - read only
- “w” - read/write
- “w+” - read/write, create if it does not exist
- “wc” - read/write, overwrite any existing file
If called with a block, the database handle will be passed to the block and the database when be closed when the block returns.
Otherwise, the method returns the database handle.
set
db.set key, value
db[key] = value
Set key in the database to value. Both should be strings.
sync
db.sync
Force database to sync to disk.
values
db.values
Returns an array of values from the database.