[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.1 dbm - Generic DBM interface

Module: dbm
DBM-like libraries provides an easy way to store values to a file, indexed by keys. You can think it as a persistent associative memory.

This modules defines <dbm> abstract class, which has a common interface to use various DBM-type database packages. As far as you operate on the already opened database, importing dbm module is enough.

To create or open a database, you need a concrete implementation of the database. Gauche currently has the following impelentations. Each module defines its own low-level accessing functions as well as the common interface. Note that your system may not have one or more of those DBM libraries; Gauche defines only what the system provides.

dbm.gdbm
GDBM library (See section 11.2 dbm.gdbm - GDBM interface).

dbm.ndbm
NDBM library (See section 11.3 dbm.ndbm - NDBM interface).

dbm.odbm
DBM library (See section 11.4 dbm.odbm - Original DBM interface).

The following code shows a typical usage of the database.

 
(use dbm)         ; dbm abstract interface
(use dbm.gdbm)    ; dbm concrete interface

; open the database
(define *db* (dbm-open <gdbm> :path "mydb" :rw-mode :write))

; put the value to the database
(dbm-put! *db* "key1" "value1")

; get the value from the database
(define val (dbm-get *db* "key1"))

; iterate over the database
(dbm-for-each *db* (lambda (key val) (foo key val)))

; close the database
(dbm-close *db*)

11.1.1 Opening and closing a dbm database  
11.1.2 Accessing a dbm database  
11.1.3 Iterating on a dbm database  



This document was generated by Ken Dickey on November, 28 2002 using texi2html