Frederick Cheung wrote: > On Sep 21, 4:09�pm, Marnen Laibow-Koser <rails-mailing-l...@andreas- > s.net> wrote: >> Perhaps it would; I've never used ActiveRecord locking at all, so I'll >> defer to you here. �However, I tend to think that locking should >> generally be implemented at the database level, not the application >> level, which is why I suggested pessimistic here. �Am I missing >> something? > > Well with optimistic locking it is ultimately the database enforcing > stuff - after all it is the only thing that can. If my memory is > correct the docs for optimistic locking have a decent explanation of > how it works.
If I understand the docs correctly, optimistic locking is *not* enforced by the database -- rather, it's up to the app to properly handle checking and updating the lock_version field. (The value is *stored* in the DB, but the DB knows nothing about using it for lock enforcement.) Pessimistic locking, by contrast, uses the DB's native locking mechanisms. This makes it far more airtight than optimistic, I think. Anyway, optimistic locking seems like reinventing the square wheel. Why bother? > > Fred Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

