Synchronized functions using PHP

后端 未结 4 2106
被撕碎了的回忆
被撕碎了的回忆 2020-12-11 02:04

How to make functions in PHP synchronized so that same function won\'t be executed concurrently ? 2nd user must wait till 1st user is done with the function. Then 2nd user

4条回答
  •  攒了一身酷
    2020-12-11 02:36

    You can use the "flock" (file locking) function with the "LOCK_EX" (exclusive lock) flag to create a custom "synchronized" function that accepts a handler to be synchronized.

    You may may found the code here.

    I hope this helps.

提交回复
热议问题