Copyright (C) 2000 Shiro Kawai (email@example.com)
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 package provides a generic interface to the various dbm-like libraries. Current version hass bridges to gdbm, ndbm and legacy dbm libraries.
You need STk version 4.0.1 or later. STk is available at http://kaolin.unice.fr/stk/. Also a generic serializer package for STk (after 0.3) is required. It is available at http://pracitcal-scheme.net/.
You should have at least one of dbm, ndbm or gdbm library. Gdbm is available at http://www.gnu.org/software/gdbm/gdbm.html.
The most recent version of the document and the package is available at the following URLs. (The package tarball includes the html document).
After ungzip and untar the package, you'll find a directory
to create a Makefile. Then
compiles necessary files. If you like to confirm everything is OK, type
to do some test. You can install the package to the site-scheme location by
<dbm> abstract class defines a common interface
to use various DBM-type database packages.
Just to operate on the already created and opened database, require
To create or open a database, you need to load at lease one of the following modules. Each module defines its own low-level accessing functions as well as the common interface.
By default, only strings are allowed to keys and values.
You can use other Scheme types for keys and values, however,
by specifying a serializer class upon the creation of the
<dbm> instance. See section 2.5 Object serialization
By instantiating a subclass of the
<dbm> class, you can
either open an existing database or create a new database.
Depending on the actual implementation, path may be used literally as a database filename (gdbm) or some suffixes are added (odbm, ndbm).
The keyword argument rw-mode takes one of the following values:
The keyword argument file-mode takes a number representing
unix file mode to be used when
make needs to create a new
database. The default is #o664. This value may be masked by
the user's umask setting.
DBM interface only takes strings for keys and values by default.
If you need to store other types of objects to the database,
you need to tell the DBM instance how to convert those objects
by serializer keyword argument.
It may take a class object which is a subclass of
or a value
#t. If it is a subclass of
a serializer instance of the class is used to convert Scheme objects.
If it is
#t, the standard external representation is used.
See section 2.5 Object serialization for details how this mechanism works.
Once a database object is created, you can use the following methods to access individual key/value pairs. Note that, unless you specify serializer argument when you create the dbm object, keys and values must be strings. See section 2.5 Object serialization for details.
<dbm>) key value
<dbm>) key &optional default
To walk over the entire database, following methos are provided.
Database file is closed when it is garbage collected. However, to ensure the modification is properly synchornized, you may want to close the database explicitly
The low-level interface to the dbm libraries only deals with strings. If you want to store general Scheme objects, you need to specify how to convert back and forth between objects and strings. Different applications need different requirements, so it's not good to implement one specific way in this library.
:serializer parameter in the constructor of dbm class,
you can specify your serialization scheme.
write*to get a string representation of the object, and
readto get the original object back. This means:
dbm-put!, but you'll have a trouble when you try to retrieve the data later.
<serializer>defines a common interface for object serialization. You can pass a serializer implemenation of your choice. See http://practical-scheme.net/vault/serializer.html about the details of serializer.
Module GDBM provides a bridge to the GDBM library. To use GDBM interface, require it as follows:
The GDBM module defines a class
These functions are direct interface to the gdbm library. See gdbm manpage for
Jump to: * - d - g - m - n - o - |
This document was generated on 11 February 2000 using texi2html 1.56k.