in reply to Multiple write locking for BerkeleyDB

DB_File works, but you do have to use flock and re-open the db each time to flush caches. MLDBM::Sync does this for you. I'm surprised MySQL didn't work for you. Did you run it on localhost and use localhost as the domain name when connecting? That tells it to use unix domain sockets which is much faster than using TCP sockets.

BerkeleyDB can definitely do what you want, but I would suggest you skip the multi-locking and just let it use a global lock. The performance you get from using it that way is good enough for nearly any perl use and it avoids deadlocking. There's some sample code using it this way in a benchmark script here.

  • Comment on Re: Multiple write locking for BerkeleyDB

Replies are listed 'Best First'.
Re^2: Multiple write locking for BerkeleyDB
by dino (Sexton) on Apr 23, 2008 at 19:05 UTC
    Thanks for the url. Wrt BerkeleyDB I was unable to find any Read Modify Write locking code. It looks like CDS was used in an automatic fashion. I'm guessing I need to invoke lock_vec and its friends but I'm not sure how.
      No, that's just it: BDB handles the locking for you. You don't need to do any explicit locking.
        I thought that with an update I need to wrap the read and the write in an overall lock. Doesn't the built in automatic locking, lock the operations separately?