Use redis to design a mechanism to mark a certain data in a locked state
迷茫
迷茫 2017-06-26 10:49:39
0
1
1248

The program goes to the database to read 10 run_status=0 data every time,

When a task is executed, the database updates fields

run_status=-1

indicates that this task is locked.

Of course, after the task execution is completed, run_status=0, indicating that the lock has been unlocked.

Now comes the problem. When executing a task, due to some exception, such as the server suddenly interrupting the program during publishing, run_status=-1 will always be in the locked state. But it's not actually being implemented.

Now you need to design a mechanism to prevent this from happening. What will you do? The current environment can use redis.

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
曾经蜡笔没有小新

I found this question too simple. Set a key with an expiration time of 60 seconds. Check whether this key exists every time

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template