How to deal with High concurrency problem with PHP FIFO

for example, you can only vote once. The program first searches whether he has voted, and then inserts records if not.
if the user votes with a concurrent tool, he can cast multiple votes if no data is found in multiple requests during the check.

can you package the code {select insert} first-in-first-out (FIFO). Only one user can go in and execute this code

Php
Mar.21,2021

store the voting information in the redis queue, and take the first vote as the standard, and then go to redis to check it. If others refuse to vote, the front end will invalidate it after clicking the button


use the redis lock to ensure that a single process is available on the Internet. Take advantage of the atomicity of redis


queue to learn about it, and use a list maintenance team with redis,. Rpush to list after each voting request arrives, and then understand that the reply is successful. The server terminal runs a php script, and while a loop,blpop list, to get the information and process it. So we can deal with one at a time.

Menu