NAME

DirDB - Perl extension to use a directory as a database

SYNOPSIS

use DirDB;
tie my %session, 'DirDB', "./data/session";

DESCRIPTION

DirDB is a package that lets you access a directory as a hash. The final directory will be created, but not the whole path to it.

The empty string, used as a key, will be translated into ' EMPTY' for purposes of storage and retrieval. File names beginning with a space are reserved for metadata for subclasses, such as object type or array size or whatever. Key names beginning with a space get an additional space prepended to the name for purposes of naming the file to store that value.

DirDB croaks on attempts to store references. There are hooks in place as of version 0.04 to do something more sensible, like recursively blatting out the whole object tree being referred to, but to prevent DirDB being involved in the possible endless loop problems, implementing such behavior is left for subclassed to do.

DirDB will croak if it can't open an existing file system entity, so wrap your fetches in eval blocks if there are possibilities of permissions problems. Or better yet rewrite it into DirDB::nonfragile and publish that.

subdirectories become references to tied objects of this type, but this is a read-only function at this time.

pipes and so on are opened for reading and read from on FETCH, and clobbered on STORE. This may change but not immediately.

The underlying object is a scalar containing the path to the directory. Keys are names within the directory, values are the contents of the files.

If anyone cares to benchmark DirDB on ReiserFS against Berkeley DB for databases of verious sizes, please send me the results and I will include them here.

STOREMETA and FETCHMETA methods are provided for subclasses who which to store and fetch metadata (such as array size) which will not appear in the data returned by NEXTKEY and which cannot be accessed directly through STORE or FETCH. DirDB::Array will store its size and so on using these methods.

EXPORT

None by default.

AUTHOR

David Nicol, davidnicol@cpan.org

Assistance

QA provided by members of Kansas City Perl Mongers, including Andrew Moore and Craig S. Cottingham.

LICENSE

GPL

SEE ALSO

better read <l perltie> before trying to extend this

GPL