in reply to Re: Best way to handle locking of nodes being edited?
in thread Best way to handle locking of nodes being edited?

If you want to prevent two editors from editing the same node simultaneously, then you'll need some form of "pessimistic" locking scheme. Obtain some form of lock up front, preventing anyone else from even attempting an edit.

Alternatively, if you judge that the chance of edit collisions is slim, you can adopt a less expensive "optimistic" scheme were the first edit saved wins. A hidden timestamp in the edit form is sufficient for this. If the timestamp doesn't match the page/node timestamp when a save is attempted, the save loses (becomes a merge attempt).

A data point:

I use an optimistic scheme in a Wiki clone. It gets far less traffic than Perlmonks, but it's often the case that there's a "working set" of a dozen active pages during the course of a day, and edit collisions are rare. Given how quickly people jump on new nodes here, that might not be the case here.

  • Comment on Re: Re: Best way to handle locking of nodes being edited?