Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Multiple write locking for BerkeleyDB

by perrin (Chancellor)
on Apr 23, 2008 at 18:30 UTC ( #682449=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://682449]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2023-10-04 13:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?