Go to the previous, next section.

Seting options.

Gdbm now supports the ability to set certain options on an already open database.

ret = gdbm_setopt(dbf, option, value, size)

The parameters are:

GDBM_FILE dbf
The pointer returned by gdbm_open.
int option
The option to be set.
int *value
A pointer to the value to which option will be set.
int size
The length of the data pointed to by value.

The valid options are currently:

GDBM_CACHESIZE - Set the size of the internal bucket cache. This option may only be set once on each GDBM_FILE descriptor, and is set automatically to 100 upon the first access to the database.

GDBM_FASTMODE - Set fast mode to either on or off. This allows fast mode to be toggled on an already open and active database. value (see below) should be set to either TRUE or FALSE.

The return value will be -1 upon failure, or 0 upon success. The global variable gdbm_errno will be set upon failure.

For instance, to set a database to use a cache of 10, after opening it with gdbm_open, but prior to accessing it in any way, the following code could be used:

int value = 10;
ret = gdbm_setopt(dbf, GDBM_CACHESIZE, &value, sizeof(int));

Go to the previous, next section.