- open-database pathname #!key flags mode page-block-power dir-block-powerprocedure
Opens existing SDBM database pathname or creates an empty database if pathname does not exist. The database resides in two files: pathname.dir (directory file) and pathname.pag (page file). Returns an opaque database object.
Optional keyword arguments are:
- flags
- flags passed to file-open, default: (+ open/rdwr open/creat)
- mode
- permissions passed to file-open, default: (+ perm/irwxu perm/irgrp perm/iroth)
- page-block-power
- bytes in each data page, as a power of 2; default: 12 (4096 bytes)
- dir-block-power
- bytes in each directory block, as a power of 2; default: 12 (4096 bytes)
The data page size limits the length of a key/value pair, so you may need to increase it to correspond with your maximum pair size. An undersized page can lead to frequent hash bucket splits and a bloated file size with many holes. An oversized page can incur disk performance overhead on read and write, since an entire page is read or written for every operation. Values between 4096 and 16384 bytes seem reasonable.
Note: The SDBM format has no database header, so you must always specify the same page-block-power and dir-block-power for a given database. The reference implementation uses page-block-power of 10 (1024 bytes) and dir-block-power of 12 (4096 bytes).