There is a possible race condition here, when there are several users searching for the same zipcode.
I propose to address this issue through implementing atomic incrementing operation (and a little simplifying by replacing if statement with upsert operation:
There is a possible race condition here, when there are several users searching for the same zipcode.
I propose to address this issue through implementing atomic incrementing operation (and a little simplifying by replacing if statement with
upsert
operation:Here we either update counter for a given zipcode (if it was found) or create a new record (if it was not found).