My script sometimes receives 2 identical requests at the same time (difference in milliseconds) from an external system.
The script, upon incoming request, makes a request to the external system, checks for the existence of an entry there, and if not, creates it.
The problem is that with simultaneous requests, the check for uniqueness fails and as a result 2 records are created.
I tried to do a random sleep but it didn't work.
$sleep = rand(1,5); sleep($sleep);