Class Gdbm.DB


Method create

Gdbm.DB Gdbm.DB(void|string file, void|string(99..119) mode)

Description

Without arguments, this function does nothing. With one argument it opens the given file as a gdbm database, if this fails for some reason, an error will be generated. If a second argument is present, it specifies how to open the database using one or more of the follow flags in a string:

r

Open database for reading

w

Open database for writing

c

Create database if it does not exist

t

Overwrite existing database

f

Fast mode

s

Synchronous mode

l

Locking mode

The fast mode prevents the database from syncronizing each change in the database immediately. This is dangerous because the database can be left in an unusable state if Pike is terminated abnormally.

The default mode is "rwc".

Note

The gdbm manual states that it is important that the database is closed properly. Unfortunately this will not be the case if Pike calls exit() or returns from main(). You should therefore make sure you call close or destruct your gdbm objects when exiting your program.

atexit might be useful.

This is very important if the database is used with the 'l' flag.