Laravel lockforupdate (Pessimistic Locking)

后端 未结 2 2088
孤独总比滥情好
孤独总比滥情好 2020-12-14 22:59

i\'m trying to figure out how to use/test the lockforupdate correctly, but i found is not function like what i expected

this is just testing

public f         


        
2条回答
  •  无人及你
    2020-12-14 23:19

    Read This Article Reference

    Pessimistic vs Optimistic Locking in Laravel

    • SharedLock:

      DB::table('users')->where('votes', '>', 100)->sharedLock()->get();
      
    • LockForUpdate:

      DB::table('users')->where('votes', '>', 100)->lockForUpdate()->get();
      

    Laravel Docs

提交回复
热议问题