Hi,

This is the Tie::DB_Lock.pm module. It is a TIEHASH class that implements a specific locking scheme when opening Berkeley (DB_File) databases.

When you open a database for writing, an exclusive lock will get placed on the database, so nobody else (nobody who pays attention to locks, that is) will be able to open the database.

When you open for reading only, a shared lock will be placed on the file, then the whole file will be copied to a temporary file, and that tempfile will be tied instead of the original file. The lock on the original file is released when we tie the tempfile. The tempfile will disappear when you close the database (or when your program dies, or whatever).

YOU MIGHT WANT TO USE THIS MODULE IF:

YOU DON'T WANT THIS MODULE IF:

If you made it through this checklist and you still think you want to use this module, congratulations. This locking scheme is the best I've come up with yet for my applications. It's simple. It lets people read from a database for as long as they want to, without blocking writes. And it won't let anyone read from or write to a database file that's being updated by someone else.

For more specific information, please see the documentation inside DB_Lock.pm, by doing "pod2txt DB_Lock.pm", or "perldoc Tie::DB_Lock" once you've installed the module.

To install the module, do the usual:

perl Makefile.PL
make
make test (optionally set TEST_VERBOSE=1 or VERY_VERBOSE=1) make install

-Ken Williams
ken@forum.swarthmore.edu