In our application, there is a code with frequent clicks that increases the column like this:
if (r = customer.find_or_generate_reminder)
r.counter += 1
r.save!
end
We get lock wait timeouts, so I'm thinking of making this an atomic operation. Naively, what I want to do is:
if (r = customer.find_or_generate_reminder)
connection.excute('UPDATE customer_reminders SET counter=counter+1, updated_at=now() WHERE id = ' + r.id)
end
Is there a way for the ruby world to do the same?
source
share