Answer the question
In order to leave comments, you need to log in
Concurrent write requests, how to filter?
Greetings.
There is an API in PHP, an android application accesses it. There are two classes in the API (class1, class2), both of which, when receiving a POST request, access the third one (class3), which writes to MySQL of the form account_id, record_time, where account_id is the id of the user who applied, and record_time is the recording time.
There is a condition in class3: if the last entry from account_id was made less than an hour ago, then do not write. The condition works correctly if requests to class1 and class2 do not occur at the same time. But the application sometimes sends two requests (from the same account_id) at the same time, i.e. accesses class1 and class2 at the same time. With such an appeal, the condition described above does not work and two records crawl into the database instead of one.
Maybe someone faced a similar problem and can suggest methods for its treatment on the server side?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question