Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/with_advisory_lock/postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ def try_lock
# pg_try_advisory_lock will either obtain the lock immediately
# and return true, or return false if the lock cannot be acquired immediately
sql = "SELECT pg_try_advisory_lock(#{numeric_lock}), #{Time.now.to_f}"
"t" == connection.select_value(sql).to_s
"t" == connection.execute(sql).first["pg_try_advisory_lock"].to_s
end

def release_lock
sql = "SELECT pg_advisory_unlock(#{numeric_lock}), #{Time.now.to_f}"
"t" == connection.select_value(sql).to_s
"t" == connection.execute(sql).first["pg_advisory_unlock"].to_s
end

def numeric_lock(name=lock_name)
Expand Down