From: Jim Cain Date: 2007-04-03T04:30:33+09:00 Subject: Re: Using transactions with secondary indexes in bdb On 4/2/07, ara.t.howard@noaa.gov wrote: > there are transaction examples in the bdb src - have you looked at that? > I looked at the one example file "txn.rb" originally, but I didn't put it all together then. Upon a second look, it's making a bit more sense. In that example, he has: module BDB class ThreadHash < Hash def start(val, num) Thread.start do self.env.begin(self) do |txn, b1| b1.delete_if do |k, v| print "\t#{num} #{k} -- #{v}\n" k == val end p "Thread #{num} Pass" Thread.pass b1.each do |k, v| print "\t#{num} #{k} -- #{v}\n" end if num == 1 txn.abort else txn.commit end end p "End Thread #{num}" end end end end And then later on he calls #start for each ThreadHash object. I suppose the business part of that is: self.env.begin(self) do |txn, b1| # ... end So he's passing in the ThreadHash object as the only argument to #begin, but the docs have this for Env#begin: begin(flags = 0, db, ...) { |txn, db, ...| ...} This says that "flags" is the first argument. Maybe that's where my confusion started. Cheers, Jim