Jeremy Kemper just added pessimistic locking to ActiveRecord:
Person.transaction do
person = Person.find(1, :lock => true)
person.visits += 1
person.save!
end
Jeremy Kemper just added pessimistic locking to ActiveRecord:
Person.transaction do
person = Person.find(1, :lock => true)
person.visits += 1
person.save!
end
{ 8 comments }
Thanks for the writeup!
I’ve written up some notes on testing rails code with concurrency issues over here
hey Tim dats a gud article for quick reference. thnx :)
Tim, there is a major error in your code above. Calling update_attribute will NOT update a single attribute – it will update the single attribute in memory then save the ENTIRE record.
Tim,
I am having trouble figuring out what this does. Can you explain for those of us new to this, and give us an example of what we could use it for?
Wow ground breaking.
Comments on this entry are closed.