in reply to Locking and synchronisation within tied hashes

This already exists: MLDBM::Sync. If that isn't exactly what you want, I still suggest you look at the code, since the synchronization part is nicely split out from the rest.

You don't need to do any locking when tie or untie, but you do have to untie and re-tie in a number of situations because of the internal caching that DB_File does. The source of MLDBM::Sync will show you when to do this.

By the way, this would all be unnecessary if you used BerkeleyDB instead. It handles locking and synchronization internally.

  • Comment on Re: Locking and synchronisation within tied hashes