I have something similar to an online chat client. When one user sends a message it will be stored in a MySQL database table with id=currentID+1
. I have another client long polling and waiting for message 'id=currentID+1'.
After this exchange, that row is never used again.
Do I need a lock in this case? The thing I'm worried about is that the reading PHP side will be able to see the row and read its values before the writing PHP side finishes creating the row.