http://www.perlmonks.org?node_id=682548


in reply to Re^4: Multiple write locking for BerkeleyDB
in thread Multiple write locking for BerkeleyDB

Try it for your benchmarks. If it turns out to be significantly faster, you can probably figure out a protocol to let you use that nearly all the time, and fall back to something slower if you need to. For example, if you use the ip as the primary key and rows are never deleted, you can:
  1. Try the update. If one row is affected, you are done.
  2. Otherwise, the row does not exist. Try an insert. If it succeeds, you are done.
  3. Otherwise, if it failed with a duplicate key, somebody else just inserted it. Retry the update.
  4. If the update fails again, something is wrong, so give up.