logo
  • 教程列表
  • SO官方文档
  • ActiveRecord 锁定
    • 乐观锁定
    • 悲观锁定
  1. StackOverflow 文档
  2. Ruby on Rails 教程
  3. ActiveRecord 锁定
  4. 乐观锁定

乐观锁定

Created: November-22, 2018

user_one = User.find(1)
user_two = User.find(1)

user_one.name = "John"
user_one.save
# Run at the same instance 
user_two.name = "Doe"
user_two.save # Raises a ActiveRecord::StaleObjectError
  • 悲观锁定
  • ActiveRecord 锁定

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明