Skip to content

Commit

Permalink
Clarify create_with_advisory_lock usage
Browse files Browse the repository at this point in the history
Explain how it mainly relates to transactions and the visibility of new records.
  • Loading branch information
Mr0grog authored and bensheldon committed Sep 2, 2020
1 parent dbcc3de commit 7d43bab
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/good_job/lockable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,15 @@ module Lockable

# @!attribute [r] create_with_advisory_lock
# @return [Boolean]
# Whether an advisory lock should be acquired immediately after creating
# the record.
# Whether an advisory lock should be acquired in the same transaction
# that created the record.
#
# This helps prevent another thread or database session from acquiring a
# lock on the record between the time you create it and the time you
# request a lock, since other sessions will not be able to see the new
# record until the transaction that creates it is completed (at which
# point you have already acquired the lock).
#
# @example
# record = MyLockableRecord.create(create_with_advisory_lock: true)
# record.advisory_locked?
Expand Down

0 comments on commit 7d43bab

Please sign in to comment.