BerkeleyDB is good if you can use the BerkeleyDB module with it's advanced locking interface, but for most things with short keys and short values SDBM_File is much faster, not to mention much easier to use. This application looks like an ideal fit for it.