开发者

Simultaneous SELECT and UPDATE - Locking to prevent concurrency problems

开发者 https://www.devze.com 2023-03-22 03:51 出处:网络
So I\'m working in an environment with high concurrency. What I want to do is select a row from the mysql database based on a certain property and then once I have that row, I want to set a \"locked\"

So I'm working in an environment with high concurrency. What I want to do is select a row from the mysql database based on a certain property and then once I have that row, I want to set a "locked" flag in the row so I can do some work in php (which could take some time) and then unlock it when I'm done. What is the best way to do this in order to prevent c开发者_开发技巧oncurrency problems that arise when having a separate SELECT and UPDATE command?


using the select for update command : http://dev.mysql.com/doc/refman/5.1/en/innodb-locking-reads.html

0

精彩评论

暂无评论...
验证码 换一张
取 消